| Total Complexity | 6 |
| Total Lines | 78 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 7 | trait InteractsWithResponse |
||
| 8 | { |
||
| 9 | /** |
||
| 10 | * The response data. |
||
| 11 | * |
||
| 12 | * @var array |
||
| 13 | */ |
||
| 14 | protected $data; |
||
| 15 | |||
| 16 | /** |
||
| 17 | * Get an attribute from the response data. |
||
| 18 | * |
||
| 19 | * @param string $key |
||
| 20 | * @param mixed $default |
||
| 21 | * @return mixed |
||
| 22 | */ |
||
| 23 | public function get($key, $default = null) |
||
| 26 | } |
||
| 27 | |||
| 28 | /** |
||
| 29 | * Set an attribute to the response data. |
||
| 30 | * |
||
| 31 | * @param string $key |
||
| 32 | * @param mixed $value |
||
| 33 | * @return array |
||
| 34 | */ |
||
| 35 | public function set($key, $value) |
||
| 36 | { |
||
| 37 | return data_set($this->data, $key, $value); |
||
| 38 | } |
||
| 39 | |||
| 40 | /** |
||
| 41 | * Determine if the given key exists in the response body. |
||
| 42 | * |
||
| 43 | * @param string|array $key |
||
| 44 | * @return bool |
||
| 45 | */ |
||
| 46 | public function exists($key) |
||
| 47 | { |
||
| 48 | $optional = new Optional($this->data); |
||
| 49 | |||
| 50 | return isset($optional[$key]); |
||
| 51 | } |
||
| 52 | |||
| 53 | /** |
||
| 54 | * Dynamically retrieve the value of an attribute. |
||
| 55 | * |
||
| 56 | * @param string $key |
||
| 57 | * @return mixed |
||
| 58 | */ |
||
| 59 | public function __get($key) |
||
| 62 | } |
||
| 63 | |||
| 64 | /** |
||
| 65 | * Dynamically set the value of an attribute. |
||
| 66 | * |
||
| 67 | * @param string $key |
||
| 68 | * @param mixed $value |
||
| 69 | * @return void |
||
| 70 | */ |
||
| 71 | public function __set($key, $value) |
||
| 74 | } |
||
| 75 | |||
| 76 | /** |
||
| 77 | * Dynamically check if an attribute is set. |
||
| 78 | * |
||
| 79 | * @param string $key |
||
| 80 | * @return bool |
||
| 81 | */ |
||
| 82 | public function __isset($key) |
||
| 87 |