api de gestion de ticket, basé sur php-crud-api. Le but est de décorrélé les outils de gestion des données, afin
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ErrorDocument.php 889B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. namespace Tqdev\PhpCrudApi\Record\Document;
  3. use Tqdev\PhpCrudApi\Record\ErrorCode;
  4. class ErrorDocument implements \JsonSerializable
  5. {
  6. public $code;
  7. public $message;
  8. public $details;
  9. public function __construct(ErrorCode $errorCode, string $argument, $details)
  10. {
  11. $this->code = $errorCode->getCode();
  12. $this->message = $errorCode->getMessage($argument);
  13. $this->details = $details;
  14. }
  15. public function getCode(): int
  16. {
  17. return $this->code;
  18. }
  19. public function getMessage(): string
  20. {
  21. return $this->message;
  22. }
  23. public function serialize()
  24. {
  25. return [
  26. 'code' => $this->code,
  27. 'message' => $this->message,
  28. 'details' => $this->details,
  29. ];
  30. }
  31. public function jsonSerialize()
  32. {
  33. return array_filter($this->serialize());
  34. }
  35. }