| Total Complexity | 5 |
| Total Lines | 58 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 10 | class CacheDataFormatter |
||
| 11 | { |
||
| 12 | /** @param mixed $data */ |
||
| 13 | private mixed $data; |
||
| 14 | |||
| 15 | /** |
||
| 16 | * CacheDataFormatter constructor. |
||
| 17 | * |
||
| 18 | * @param mixed $data |
||
| 19 | */ |
||
| 20 | public function __construct(mixed $data) |
||
| 23 | } |
||
| 24 | |||
| 25 | /** |
||
| 26 | * Converts the data to JSON format. |
||
| 27 | * |
||
| 28 | * @return string|false |
||
| 29 | */ |
||
| 30 | public function toJson(): bool|string |
||
| 31 | { |
||
| 32 | return json_encode( |
||
| 33 | $this->data, |
||
| 34 | JSON_PRETTY_PRINT | |
||
| 35 | JSON_UNESCAPED_UNICODE | |
||
| 36 | JSON_UNESCAPED_SLASHES |
||
| 37 | ); |
||
| 38 | } |
||
| 39 | |||
| 40 | /** |
||
| 41 | * Converts the data to an array. |
||
| 42 | * |
||
| 43 | * @return array |
||
| 44 | */ |
||
| 45 | public function toArray(): array |
||
| 46 | { |
||
| 47 | return (array)$this->data; |
||
| 48 | } |
||
| 49 | |||
| 50 | /** |
||
| 51 | * Converts the data to a string. |
||
| 52 | * |
||
| 53 | * @return string |
||
| 54 | */ |
||
| 55 | public function toString(): string |
||
| 58 | } |
||
| 59 | |||
| 60 | /** |
||
| 61 | * Converts the data to an object. |
||
| 62 | * |
||
| 63 | * @return object |
||
| 64 | */ |
||
| 65 | public function toObject(): object |
||
| 68 | } |
||
| 69 | } |
||
| 70 |