<?php
namespace App\Lidia; abstract class ResponseAbstract { protected $status; protected $message; public function setStatus($status) { $this->status = $status; return $this; } public function setMessage($message) { $this->message = $message; return $this; } public function check() { $msgs = new \App\MessagesCollector(); if (!$this->status) { $msgs->addError("The response from LIDIA is not complete. Please verify the logs."); } if (in_array($this->status, ['invalid', 'error'])) { $msgs->addError(sprintf("The status response is `%s`. Message returned: `%s`", $this->status, $this->message)); } $this->doCheck($msgs); if ($msgs->hasErrorOrWarning()) { throw new \App\MessagesException($msgs); } } abstract protected function doCheck(\App\MessagesCollector $msgs); } 