Total Complexity | 12 |
Total Lines | 90 |
Duplicated Lines | 0 % |
Coverage | 30% |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
11 | trait HasDataTrait |
||
12 | { |
||
13 | /** |
||
14 | * @var ResponseData |
||
15 | */ |
||
16 | public $data; |
||
17 | |||
18 | 3 | /** |
|
19 | * @inheritDoc |
||
20 | 3 | */ |
|
21 | 3 | public function offsetExists($offset): bool |
|
22 | { |
||
23 | return $this->data->has($offset); |
||
24 | } |
||
25 | |||
26 | /** |
||
27 | * @inheritDoc |
||
28 | */ |
||
29 | public function offsetGet($offset) |
||
30 | { |
||
31 | return $this->data->get($offset); |
||
32 | } |
||
33 | |||
34 | /** |
||
35 | * @inheritDoc |
||
36 | */ |
||
37 | public function offsetSet($offset, $value) |
||
38 | { |
||
39 | $this->set($offset, $value); |
||
40 | } |
||
41 | |||
42 | /** |
||
43 | * @inheritDoc |
||
44 | */ |
||
45 | public function offsetUnset($offset) |
||
46 | { |
||
47 | $this->data->unset($offset); |
||
48 | } |
||
49 | |||
50 | /** |
||
51 | * @param string $key |
||
52 | * @return mixed|null |
||
53 | */ |
||
54 | public function __get(string $key) |
||
55 | { |
||
56 | return $this->data->get($key); |
||
57 | } |
||
58 | |||
59 | /** |
||
60 | * @param $name |
||
61 | * @param $value |
||
62 | */ |
||
63 | public function __set($name, $value) |
||
64 | { |
||
65 | $this->data->set($name, $value); |
||
66 | } |
||
67 | |||
68 | /** |
||
69 | * @param $name |
||
70 | * @param $value |
||
71 | */ |
||
72 | public function set($name, $value) |
||
73 | { |
||
74 | $this->data->set($name, $value); |
||
75 | } |
||
76 | |||
77 | /** |
||
78 | * @param $name |
||
79 | * @param $value |
||
80 | */ |
||
81 | public function with($key, $value = null) |
||
82 | { |
||
83 | $data = is_array($key) ? $key : [$key => $value]; |
||
84 | |||
85 | foreach ($data as $key => $value) { |
||
|
|||
86 | $this->set($key, $value); |
||
87 | } |
||
88 | } |
||
89 | |||
90 | /** |
||
91 | * @return mixed |
||
92 | */ |
||
93 | public function all() |
||
94 | { |
||
95 | return $this->data->all(); |
||
96 | } |
||
97 | |||
98 | protected function initData() |
||
101 | } |
||
102 | } |
||
103 |