@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | /** |
| 16 | 16 | * @link http://api.prototypejs.org/language/Enumerable/ |
| 17 | 17 | */ |
| 18 | -trait Enumerable{ |
|
| 18 | +trait Enumerable { |
|
| 19 | 19 | |
| 20 | 20 | /** |
| 21 | 21 | * @var array |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | * |
| 46 | 46 | * @return $this |
| 47 | 47 | */ |
| 48 | - public function __each($callback){ |
|
| 48 | + public function __each($callback) { |
|
| 49 | 49 | $this->__map($callback); |
| 50 | 50 | |
| 51 | 51 | return $this; |
@@ -62,13 +62,13 @@ discard block |
||
| 62 | 62 | */ |
| 63 | 63 | public function __map($callback):array { |
| 64 | 64 | |
| 65 | - if(!is_callable($callback)){ |
|
| 65 | + if (!is_callable($callback)) { |
|
| 66 | 66 | throw new TraitException('invalid callback'); |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | $return = []; |
| 70 | 70 | |
| 71 | - foreach($this->array as $index => $element){ |
|
| 71 | + foreach ($this->array as $index => $element) { |
|
| 72 | 72 | $return[$index] = call_user_func_array($callback, [$element, $index]); |
| 73 | 73 | } |
| 74 | 74 | |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | * |
| 81 | 81 | * @return $this |
| 82 | 82 | */ |
| 83 | - public function __reverse(){ |
|
| 83 | + public function __reverse() { |
|
| 84 | 84 | $this->array = array_reverse($this->array); |
| 85 | 85 | $this->offset = 0; |
| 86 | 86 | |
@@ -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,31 +27,31 @@ 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 === null ? $class : $type; |
| 32 | 32 | |
| 33 | - try{ |
|
| 33 | + try { |
|
| 34 | 34 | $reflectionClass = new ReflectionClass($class); |
| 35 | 35 | $reflectionType = new ReflectionClass($type); |
| 36 | 36 | |
| 37 | - if($reflectionType->isTrait()){ |
|
| 37 | + if ($reflectionType->isTrait()) { |
|
| 38 | 38 | trigger_error($class.' cannot be an instance of trait '.$type); |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | - if($reflectionClass->isAbstract()){ |
|
| 41 | + if ($reflectionClass->isAbstract()) { |
|
| 42 | 42 | trigger_error('cannot instance abstract class '.$class); |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | - if($reflectionClass->isTrait()){ |
|
| 45 | + if ($reflectionClass->isTrait()) { |
|
| 46 | 46 | trigger_error('cannot instance trait '.$class); |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | - if($class !== $type){ |
|
| 49 | + if ($class !== $type) { |
|
| 50 | 50 | |
| 51 | - if($reflectionType->isInterface() && !$reflectionClass->implementsInterface($type)){ |
|
| 51 | + if ($reflectionType->isInterface() && !$reflectionClass->implementsInterface($type)) { |
|
| 52 | 52 | trigger_error($class.' does not implement '.$type); |
| 53 | 53 | } |
| 54 | - elseif(!$reflectionClass->isSubclassOf($type)) { |
|
| 54 | + elseif (!$reflectionClass->isSubclassOf($type)) { |
|
| 55 | 55 | trigger_error($class.' does not inherit '.$type); |
| 56 | 56 | } |
| 57 | 57 | |
@@ -59,13 +59,13 @@ discard block |
||
| 59 | 59 | |
| 60 | 60 | $object = $reflectionClass->newInstanceArgs($params); |
| 61 | 61 | |
| 62 | - if(!$object instanceof $type){ |
|
| 62 | + if (!$object instanceof $type) { |
|
| 63 | 63 | trigger_error('how did u even get here?'); // @codeCoverageIgnore |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | return $object; |
| 67 | 67 | } |
| 68 | - catch(Exception $e){ |
|
| 68 | + catch (Exception $e) { |
|
| 69 | 69 | throw new TraitException('ClassLoader: '.$e->getMessage()); |
| 70 | 70 | } |
| 71 | 71 | |