@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | |
15 | 15 | use Exception, ReflectionClass; |
16 | 16 | |
17 | -trait ClassLoader{ |
|
17 | +trait ClassLoader { |
|
18 | 18 | |
19 | 19 | /** |
20 | 20 | * Instances an object of $class/$type with an arbitrary number of $params |
@@ -27,45 +27,45 @@ discard block |
||
27 | 27 | * @return mixed of type $type |
28 | 28 | * @throws \Exception |
29 | 29 | */ |
30 | - public function loadClass(string $class, string $type = null, ...$params){ |
|
30 | + public function loadClass(string $class, string $type = null, ...$params) { |
|
31 | 31 | $type = $type ?? $class; |
32 | 32 | |
33 | - try{ |
|
33 | + try { |
|
34 | 34 | $reflectionClass = new ReflectionClass($class); |
35 | 35 | $reflectionType = new ReflectionClass($type); |
36 | 36 | } |
37 | - catch(Exception $e){ |
|
37 | + catch (Exception $e) { |
|
38 | 38 | throw new TraitException('ClassLoader: '.$e->getMessage()); |
39 | 39 | } |
40 | 40 | |
41 | 41 | |
42 | - if($reflectionType->isTrait()){ |
|
42 | + if ($reflectionType->isTrait()) { |
|
43 | 43 | throw new TraitException($class.' cannot be an instance of trait '.$type); |
44 | 44 | } |
45 | 45 | |
46 | - if($reflectionClass->isAbstract()){ |
|
46 | + if ($reflectionClass->isAbstract()) { |
|
47 | 47 | throw new TraitException('cannot instance abstract class '.$class); |
48 | 48 | } |
49 | 49 | |
50 | - if($reflectionClass->isTrait()){ |
|
50 | + if ($reflectionClass->isTrait()) { |
|
51 | 51 | throw new TraitException('cannot instance trait '.$class); |
52 | 52 | } |
53 | 53 | |
54 | - if($class !== $type){ |
|
54 | + if ($class !== $type) { |
|
55 | 55 | |
56 | - if($reflectionType->isInterface() && !$reflectionClass->implementsInterface($type)){ |
|
56 | + if ($reflectionType->isInterface() && !$reflectionClass->implementsInterface($type)) { |
|
57 | 57 | throw new TraitException($class.' does not implement '.$type); |
58 | 58 | } |
59 | - elseif(!$reflectionClass->isSubclassOf($type)) { |
|
59 | + elseif (!$reflectionClass->isSubclassOf($type)) { |
|
60 | 60 | throw new TraitException($class.' does not inherit '.$type); |
61 | 61 | } |
62 | 62 | |
63 | 63 | } |
64 | 64 | |
65 | - try{ |
|
65 | + try { |
|
66 | 66 | $object = $reflectionClass->newInstanceArgs($params); |
67 | 67 | |
68 | - if(!$object instanceof $type){ |
|
68 | + if (!$object instanceof $type) { |
|
69 | 69 | throw new TraitException('how did u even get here?'); // @codeCoverageIgnore |
70 | 70 | } |
71 | 71 | |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | } |
74 | 74 | // @codeCoverageIgnoreStart |
75 | 75 | // here be dragons |
76 | - catch(Exception $e){ |
|
76 | + catch (Exception $e) { |
|
77 | 77 | throw new TraitException('ClassLoader: '.$e->getMessage()); |
78 | 78 | } |
79 | 79 | // @codeCoverageIgnoreEnd |
@@ -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(); |
34 | 34 | } |
35 | - elseif($array instanceof Traversable){ |
|
35 | + elseif ($array instanceof Traversable) { |
|
36 | 36 | $this->array = iterator_to_array($array); |
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); |
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 | |
@@ -71,9 +71,9 @@ discard block |
||
71 | 71 | |
72 | 72 | $matches = []; |
73 | 73 | |
74 | - foreach($this->iterator as $v){ |
|
74 | + foreach ($this->iterator as $v) { |
|
75 | 75 | |
76 | - if($v === $value){ |
|
76 | + if ($v === $value) { |
|
77 | 77 | $matches[$this->getPath()] = $value; |
78 | 78 | } |
79 | 79 | |
@@ -89,9 +89,9 @@ discard block |
||
89 | 89 | */ |
90 | 90 | public function isset(string $dotKey):bool{ |
91 | 91 | |
92 | - foreach($this->iterator as $v){ |
|
92 | + foreach ($this->iterator as $v) { |
|
93 | 93 | |
94 | - if($this->getPath() === $dotKey){ |
|
94 | + if ($this->getPath() === $dotKey) { |
|
95 | 95 | return true; |
96 | 96 | } |
97 | 97 |