Conditions | 5 |
Paths | 5 |
Total Lines | 22 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
24 | public function get($attribute) |
||
25 | { |
||
26 | if ($attribute === null) { |
||
|
|||
27 | return new Attribute($attribute); |
||
28 | } |
||
29 | |||
30 | if (isset($this->data[$attribute])) { |
||
31 | return new Attribute($attribute, $this->data[$attribute]); |
||
32 | } |
||
33 | |||
34 | $segments = explode('.', $attribute); |
||
35 | $data = null; |
||
36 | |||
37 | foreach ($segments as $segment) { |
||
38 | if (!array_key_exists($segment, $this->data)) { |
||
39 | return new Attribute($attribute); |
||
40 | } |
||
41 | |||
42 | $data = $this->data[$segment]; |
||
43 | } |
||
44 | |||
45 | return new Attribute($attribute, $data); |
||
46 | } |
||
48 |