@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | |
15 | 15 | use ArrayIterator, ArrayObject, RecursiveArrayIterator, RecursiveIteratorIterator, Traversable; |
16 | 16 | |
17 | -trait SearchableArray{ |
|
17 | +trait SearchableArray { |
|
18 | 18 | use DotArray; |
19 | 19 | |
20 | 20 | /** |
@@ -27,19 +27,19 @@ discard block |
||
27 | 27 | * |
28 | 28 | * @param array|object|\Traversable|\ArrayIterator|\ArrayObject|null $array |
29 | 29 | */ |
30 | - public function __construct($array = null){ |
|
30 | + public function __construct($array = null) { |
|
31 | 31 | |
32 | - if(($array instanceof ArrayObject) || ($array instanceof ArrayIterator)){ |
|
32 | + if (($array instanceof ArrayObject) || ($array instanceof ArrayIterator)) { |
|
33 | 33 | $this->array = $array->getArrayCopy(); // @codeCoverageIgnore |
34 | 34 | } |
35 | - elseif($array instanceof Traversable){ |
|
35 | + elseif ($array instanceof Traversable) { |
|
36 | 36 | $this->array = iterator_to_array($array); // @codeCoverageIgnore |
37 | 37 | } |
38 | 38 | // yields unexpected results with DotArray |
39 | - elseif(gettype($array) === 'object'){ |
|
39 | + elseif (gettype($array) === 'object') { |
|
40 | 40 | $this->array = get_object_vars($array); // @codeCoverageIgnore |
41 | 41 | } |
42 | - elseif(is_array($array)){ |
|
42 | + elseif (is_array($array)) { |
|
43 | 43 | $this->array = $array; |
44 | 44 | } |
45 | 45 | |
@@ -54,11 +54,11 @@ discard block |
||
54 | 54 | * |
55 | 55 | * @return mixed |
56 | 56 | */ |
57 | - public function searchByKey(string $dotKey){ |
|
57 | + public function searchByKey(string $dotKey) { |
|
58 | 58 | |
59 | - foreach($this->iterator as $v){ |
|
59 | + foreach ($this->iterator as $v) { |
|
60 | 60 | |
61 | - if($this->getPath() === $dotKey){ |
|
61 | + if ($this->getPath() === $dotKey) { |
|
62 | 62 | return $v; |
63 | 63 | } |
64 | 64 | |
@@ -76,9 +76,9 @@ discard block |
||
76 | 76 | |
77 | 77 | $matches = []; |
78 | 78 | |
79 | - foreach($this->iterator as $v){ |
|
79 | + foreach ($this->iterator as $v) { |
|
80 | 80 | |
81 | - if($v === $value){ |
|
81 | + if ($v === $value) { |
|
82 | 82 | $matches[$this->getPath()] = $value; |
83 | 83 | } |
84 | 84 | |
@@ -94,9 +94,9 @@ discard block |
||
94 | 94 | */ |
95 | 95 | public function isset(string $dotKey):bool{ |
96 | 96 | |
97 | - foreach($this->iterator as $v){ |
|
97 | + foreach ($this->iterator as $v) { |
|
98 | 98 | |
99 | - if($this->getPath() === $dotKey){ |
|
99 | + if ($this->getPath() === $dotKey) { |
|
100 | 100 | return true; |
101 | 101 | } |
102 | 102 |
@@ -31,15 +31,13 @@ |
||
31 | 31 | |
32 | 32 | if(($array instanceof ArrayObject) || ($array instanceof ArrayIterator)){ |
33 | 33 | $this->array = $array->getArrayCopy(); // @codeCoverageIgnore |
34 | - } |
|
35 | - elseif($array instanceof Traversable){ |
|
34 | + } elseif($array instanceof Traversable){ |
|
36 | 35 | $this->array = iterator_to_array($array); // @codeCoverageIgnore |
37 | 36 | } |
38 | 37 | // yields unexpected results with DotArray |
39 | 38 | elseif(gettype($array) === 'object'){ |
40 | 39 | $this->array = get_object_vars($array); // @codeCoverageIgnore |
41 | - } |
|
42 | - elseif(is_array($array)){ |
|
40 | + } elseif(is_array($array)){ |
|
43 | 41 | $this->array = $array; |
44 | 42 | } |
45 | 43 |