| Total Complexity | 7 |
| Total Lines | 57 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 21 | trait Body |
||
| 22 | { |
||
| 23 | |||
| 24 | /** |
||
| 25 | * Response |
||
| 26 | * @var array |
||
| 27 | */ |
||
| 28 | private static $__response = []; |
||
| 29 | |||
| 30 | /** |
||
| 31 | * Checks if response contains a data by given key |
||
| 32 | * @param string $key |
||
| 33 | * @return bool |
||
| 34 | */ |
||
| 35 | public static function has(string $key): bool |
||
| 36 | { |
||
| 37 | return isset(self::$__response[$key]); |
||
| 38 | } |
||
| 39 | |||
| 40 | /** |
||
| 41 | * Gets the data from response by given key |
||
| 42 | * @param string $key |
||
| 43 | * @param string|null $default |
||
| 44 | * @return mixed |
||
| 45 | */ |
||
| 46 | public static function get(string $key, string $default = null) |
||
| 49 | } |
||
| 50 | |||
| 51 | /** |
||
| 52 | * Sets new key/value pair into response |
||
| 53 | * @param string $key |
||
| 54 | * @param mixed $value |
||
| 55 | */ |
||
| 56 | public static function set(string $key, $value) |
||
| 57 | { |
||
| 58 | self::$__response[$key] = $value; |
||
| 59 | } |
||
| 60 | |||
| 61 | /** |
||
| 62 | * Gets all response parameters |
||
| 63 | * @return array |
||
| 64 | */ |
||
| 65 | public static function all(): array |
||
| 66 | { |
||
| 67 | return self::$__response; |
||
| 68 | } |
||
| 69 | |||
| 70 | /** |
||
| 71 | * Deletes the element from response by given key |
||
| 72 | * @param string $key |
||
| 73 | */ |
||
| 74 | public static function delete(string $key) |
||
| 78 | } |
||
| 79 | } |
||
| 80 | |||
| 81 | } |