| 1 | <?php |
||
| 8 | class JsonResponse implements ResponseInterface |
||
| 9 | { |
||
| 10 | /** |
||
| 11 | * @var array|string |
||
| 12 | */ |
||
| 13 | protected $data; |
||
| 14 | |||
| 15 | /** |
||
| 16 | * @var int |
||
| 17 | */ |
||
| 18 | protected $httpCode; |
||
| 19 | |||
| 20 | /** |
||
| 21 | * Response constructor. |
||
| 22 | * |
||
| 23 | * @param string $data |
||
| 24 | * @param int $httpCode |
||
| 25 | */ |
||
| 26 | public function __construct($data, $httpCode) |
||
| 39 | |||
| 40 | /** |
||
| 41 | * Returns data represented as string. |
||
| 42 | * |
||
| 43 | * @return string |
||
| 44 | */ |
||
| 45 | public function __toString() |
||
| 53 | |||
| 54 | /** |
||
| 55 | * {@inheritdoc} |
||
| 56 | */ |
||
| 57 | public function getStatusCode() |
||
| 61 | |||
| 62 | /** |
||
| 63 | * {@inheritdoc} |
||
| 64 | */ |
||
| 65 | public function getData() |
||
| 69 | |||
| 70 | /** |
||
| 71 | * {@inheritdoc} |
||
| 72 | */ |
||
| 73 | public function isOk() |
||
| 81 | |||
| 82 | /** |
||
| 83 | * {@inheritdoc} |
||
| 84 | */ |
||
| 85 | public function isAuthorized() |
||
| 93 | |||
| 94 | /** |
||
| 95 | * {@inheritdoc} |
||
| 96 | */ |
||
| 97 | public function getMessage() |
||
| 105 | |||
| 106 | /** |
||
| 107 | * Checks if given string is valid json. |
||
| 108 | * |
||
| 109 | * @param string $string |
||
| 110 | * |
||
| 111 | * @return bool |
||
| 112 | */ |
||
| 113 | protected function isValidJson($string) |
||
| 119 | } |
||
| 120 |