Completed
Push — master ( 264759...40d38a )
by smiley
04:42
created
src/ArrayHelpers/SearchableArray.php 2 patches
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -31,15 +31,13 @@
 block discarded – undo
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
 
Please login to merge, or discard this patch.