| Total Complexity | 4 |
| Total Lines | 28 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 7 | class ResponseHandler |
||
| 8 | { |
||
| 9 | private static array $response = [ |
||
| 10 | 'valid' => true, |
||
| 11 | 'filename' => null, |
||
| 12 | 'errors' => [] |
||
| 13 | ]; |
||
| 14 | |||
| 15 | /** |
||
| 16 | * Set errors and save in array called $response. |
||
| 17 | * @param string $message - Error description. |
||
| 18 | */ |
||
| 19 | public static function fail(string $message) |
||
| 20 | { |
||
| 21 | if (self::$response['valid']) { |
||
| 22 | self::$response['valid'] = false; |
||
| 23 | } |
||
| 24 | array_push(self::$response['errors'], $message); |
||
| 25 | } |
||
| 26 | |||
| 27 | protected static function filename(string $name) |
||
| 28 | { |
||
| 29 | self::$response['filename'] = $name; |
||
| 30 | } |
||
| 31 | |||
| 32 | protected static function arrayResponse(): array |
||
| 35 | } |
||
| 36 | } |
||
| 37 |