Passed
Push — master ( e4897b...79b76a )
by smiley
01:48
created
src/ArrayHelpers/ArraySearch.php 2 patches
Spacing   +12 added lines, -12 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
-class ArraySearch{
17
+class ArraySearch {
18 18
 
19 19
 	/**
20 20
 	 * @var \IteratorIterator|\RecursiveIteratorIterator
@@ -31,21 +31,21 @@  discard block
 block discarded – undo
31 31
 	 *
32 32
 	 * @param array|object|\Traversable|\ArrayIterator|\ArrayObject|null $array
33 33
 	 */
34
-	public function __construct($array = null){
34
+	public function __construct($array = null) {
35 35
 
36
-		if(($array instanceof ArrayObject) || ($array instanceof ArrayIterator)){
36
+		if (($array instanceof ArrayObject) || ($array instanceof ArrayIterator)) {
37 37
 			$this->array = $array->getArrayCopy();
38 38
 		}
39
-		elseif($array instanceof Traversable){
39
+		elseif ($array instanceof Traversable) {
40 40
 			$this->array = iterator_to_array($array);
41 41
 		}
42
-		elseif(gettype($array) === 'object'){
42
+		elseif (gettype($array) === 'object') {
43 43
 			$this->array = get_object_vars($array);
44 44
 		}
45
-		elseif(is_array($array)){
45
+		elseif (is_array($array)) {
46 46
 			$this->array = $array;
47 47
 		}
48
-		else{
48
+		else {
49 49
 			$this->array = [];
50 50
 		}
51 51
 
@@ -56,12 +56,12 @@  discard block
 block discarded – undo
56 56
 	 *
57 57
 	 * @return mixed
58 58
 	 */
59
-	public function arraySearch(string $dotKey){
59
+	public function arraySearch(string $dotKey) {
60 60
 		$this->iterator = $this->getRecursiveIteratorIterator();
61 61
 
62
-		foreach($this->iterator as $v){
62
+		foreach ($this->iterator as $v) {
63 63
 
64
-			if($this->getPath() === $dotKey){
64
+			if ($this->getPath() === $dotKey) {
65 65
 				return $v;
66 66
 			}
67 67
 
@@ -78,9 +78,9 @@  discard block
 block discarded – undo
78 78
 	public function arrayIsset(string $dotKey):bool{
79 79
 		$this->iterator = $this->getRecursiveIteratorIterator();
80 80
 
81
-		foreach($this->iterator as $v){
81
+		foreach ($this->iterator as $v) {
82 82
 
83
-			if($this->getPath() === $dotKey){
83
+			if ($this->getPath() === $dotKey) {
84 84
 				return true;
85 85
 			}
86 86
 
Please login to merge, or discard this patch.
Braces   +4 added lines, -8 removed lines patch added patch discarded remove patch
@@ -35,17 +35,13 @@
 block discarded – undo
35 35
 
36 36
 		if(($array instanceof ArrayObject) || ($array instanceof ArrayIterator)){
37 37
 			$this->array = $array->getArrayCopy();
38
-		}
39
-		elseif($array instanceof Traversable){
38
+		} elseif($array instanceof Traversable){
40 39
 			$this->array = iterator_to_array($array);
41
-		}
42
-		elseif(gettype($array) === 'object'){
40
+		} elseif(gettype($array) === 'object'){
43 41
 			$this->array = get_object_vars($array);
44
-		}
45
-		elseif(is_array($array)){
42
+		} elseif(is_array($array)){
46 43
 			$this->array = $array;
47
-		}
48
-		else{
44
+		} else{
49 45
 			$this->array = [];
50 46
 		}
51 47
 
Please login to merge, or discard this patch.
src/ArrayHelpers/DotArray.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 /**
16 16
  * @link https://github.com/laravel/framework/blob/5.4/src/Illuminate/Support/Arr.php
17 17
  */
18
-trait DotArray{
18
+trait DotArray {
19 19
 
20 20
 	/**
21 21
 	 *  Checks if $key isset in $array using dot notation and returns it on success.
@@ -26,15 +26,15 @@  discard block
 block discarded – undo
26 26
 	 *
27 27
 	 * @return mixed returns $array[$key], $default otherwise.
28 28
 	 */
29
-	protected function arrayGet(array $array, string $key, $default = null){
29
+	protected function arrayGet(array $array, string $key, $default = null) {
30 30
 
31
-		if(isset($array[$key])){
31
+		if (isset($array[$key])) {
32 32
 			return $array[$key];
33 33
 		}
34 34
 
35
-		foreach(explode('.', $key) as $segment){
35
+		foreach (explode('.', $key) as $segment) {
36 36
 
37
-			if(!is_array($array) || !array_key_exists($segment, $array)){
37
+			if (!is_array($array) || !array_key_exists($segment, $array)) {
38 38
 				return $default;
39 39
 			}
40 40
 
@@ -54,17 +54,17 @@  discard block
 block discarded – undo
54 54
 	 */
55 55
 	protected function arrayIn(array $array, string $key):bool{
56 56
 
57
-		if(empty($array)){
57
+		if (empty($array)) {
58 58
 			return false;
59 59
 		}
60 60
 
61
-		if(array_key_exists($key, $array)){
61
+		if (array_key_exists($key, $array)) {
62 62
 			return true;
63 63
 		}
64 64
 
65
-		foreach(explode('.', $key) as $segment){
65
+		foreach (explode('.', $key) as $segment) {
66 66
 
67
-			if(!is_array($array) || !array_key_exists($segment, $array)){
67
+			if (!is_array($array) || !array_key_exists($segment, $array)) {
68 68
 				return false;
69 69
 			}
70 70
 
@@ -85,21 +85,21 @@  discard block
 block discarded – undo
85 85
 	 *
86 86
 	 * @return array
87 87
 	 */
88
-	protected function arraySet(array &$array, string $key, $value){
88
+	protected function arraySet(array &$array, string $key, $value) {
89 89
 
90
-		if(is_null($key)){
90
+		if (is_null($key)) {
91 91
 			return $array = $value;
92 92
 		}
93 93
 
94 94
 		$keys = explode('.', $key);
95 95
 
96
-		while(count($keys) > 1){
96
+		while (count($keys) > 1) {
97 97
 			$key = array_shift($keys);
98 98
 
99 99
 			// If the key doesn't exist at this depth, we will just create an empty array
100 100
 			// to hold the next value, allowing us to create the arrays to hold final
101 101
 			// values at the correct depth. Then we'll keep digging into the array.
102
-			if(!isset($array[$key]) || !is_array($array[$key])){
102
+			if (!isset($array[$key]) || !is_array($array[$key])) {
103 103
 				$array[$key] = [];
104 104
 			}
105 105
 
Please login to merge, or discard this patch.