Passed
Push — master ( ec3914...4b07de )
by smiley
01:47
created
src/DotEnv.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
  * @method void unset(string $var)
24 24
  * @method DotEnv clear()
25 25
  */
26
-class DotEnv{
26
+class DotEnv {
27 27
 	use Env{
28 28
 		// allow a magic getter & setter
29 29
 		__getEnv as public __get;
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 	 * @param string|null $filename
58 58
 	 * @param bool|null   $global
59 59
 	 */
60
-	public function __construct(string $path, string $filename = null, bool $global = null){
60
+	public function __construct(string $path, string $filename = null, bool $global = null) {
61 61
 		$this->path     = $path;
62 62
 		$this->filename = $filename;
63 63
 		$this->_global  = $global ?? true; // emulate vlucas/dotenv behaviour by default
Please login to merge, or discard this patch.
src/ArrayHelpers/ByteArray.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 /**
18 18
  * @extends \SplFixedArray
19 19
  */
20
-class ByteArray extends SplFixedArray{
20
+class ByteArray extends SplFixedArray {
21 21
 
22 22
 	/**
23 23
 	 * @return string
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 	 * @return string
31 31
 	 */
32 32
 	public function toHex():string{
33
-		return $this->map(function($v){
33
+		return $this->map(function($v) {
34 34
 			return str_pad(dechex($v), '2', '0', STR_PAD_LEFT);
35 35
 		});
36 36
 	}
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 	 * @return string
54 54
 	 */
55 55
 	public function toBin():string{
56
-		return $this->map(function($v){
56
+		return $this->map(function($v) {
57 57
 			return str_pad(decbin($v), '8', '0', STR_PAD_LEFT);
58 58
 		});
59 59
 	}
@@ -82,11 +82,11 @@  discard block
 block discarded – undo
82 82
 
83 83
 		$diff = $offset + $length;
84 84
 
85
-		if($diff > $this->count()){
85
+		if ($diff > $this->count()) {
86 86
 			$this->setSize($diff);
87 87
 		}
88 88
 
89
-		for($i = 0; $i < $length; $i++){
89
+		for ($i = 0; $i < $length; $i++) {
90 90
 			$this[$i + $offset] = $src[$i + $srcOffset];
91 91
 		}
92 92
 
@@ -103,9 +103,9 @@  discard block
 block discarded – undo
103 103
 
104 104
 		// keep an extended class
105 105
 		/** @var \chillerlan\Traits\ArrayHelpers\ByteArray $slice */
106
-		$slice  = (new ReflectionClass($this))->newInstanceArgs([$length ?? ($this->count() - $offset)]);
106
+		$slice = (new ReflectionClass($this))->newInstanceArgs([$length ?? ($this->count() - $offset)]);
107 107
 
108
-		foreach($slice as $i => $_){
108
+		foreach ($slice as $i => $_) {
109 109
 			$slice[$i] = $this[$offset + $i];
110 110
 		}
111 111
 
@@ -119,13 +119,13 @@  discard block
 block discarded – undo
119 119
 	 */
120 120
 	public function equal(SplFixedArray $array):bool{
121 121
 
122
-		if($this->count() !== $array->count()){
122
+		if ($this->count() !== $array->count()) {
123 123
 			return false;
124 124
 		}
125 125
 
126 126
 		$diff = 0;
127 127
 
128
-		foreach($this as $k => $v){
128
+		foreach ($this as $k => $v) {
129 129
 			$diff |= $v ^ $array[$k];
130 130
 		}
131 131
 
Please login to merge, or discard this patch.
src/Interfaces/ArrayAccessTrait.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
  *
18 18
  * @link http://php.net/manual/class.arrayaccess.php
19 19
  */
20
-trait ArrayAccessTrait{
20
+trait ArrayAccessTrait {
21 21
 
22 22
 	/**
23 23
 	 * @var array
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 	 * @link  http://php.net/manual/arrayaccess.offsetget.php
42 42
 	 * @inheritdoc
43 43
 	 */
44
-	public function offsetGet($offset){
44
+	public function offsetGet($offset) {
45 45
 		return $this->array[$offset] ?? null;
46 46
 	}
47 47
 
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 	 * @link  http://php.net/manual/arrayaccess.offsetset.php
50 50
 	 * @inheritdoc
51 51
 	 */
52
-	public function offsetSet($offset, $value){
52
+	public function offsetSet($offset, $value) {
53 53
 
54 54
 		$offset !== null
55 55
 			? $this->array[$offset] = $value
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 	 * @link  http://php.net/manual/arrayaccess.offsetunset.php
61 61
 	 * @inheritdoc
62 62
 	 */
63
-	public function offsetUnset($offset){
63
+	public function offsetUnset($offset) {
64 64
 		unset($this->array[$offset]);
65 65
 	}
66 66
 
Please login to merge, or discard this patch.
src/ContainerInterface.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@
 block discarded – undo
13 13
 /**
14 14
  * a generic container with magic getter and setter
15 15
  */
16
-interface ContainerInterface{
16
+interface ContainerInterface {
17 17
 
18 18
 	/**
19 19
 	 * @param iterable $properties
Please login to merge, or discard this patch.
src/Container.php 2 patches
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -46,8 +46,7 @@  discard block
 block discarded – undo
46 46
 
47 47
 		if($this->__isset($property)){
48 48
 			return $this->{$property};
49
-		}
50
-		elseif($this->env instanceof DotEnv){
49
+		} elseif($this->env instanceof DotEnv){
51 50
 			return $this->env->get($property);
52 51
 		}
53 52
 
@@ -65,8 +64,7 @@  discard block
 block discarded – undo
65 64
 		// avoid overwriting private properties
66 65
 		if(property_exists($this, $property) && !$this->__isPrivate($property)){
67 66
 			$this->{$property} = $value;
68
-		}
69
-		elseif($this->env instanceof DotEnv){
67
+		} elseif($this->env instanceof DotEnv){
70 68
 			$this->env->set($property, $value);
71 69
 		}
72 70
 
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 /**
18 18
  * a generic container with magic getter and setter
19 19
  */
20
-trait Container{
20
+trait Container {
21 21
 
22 22
 	/**
23 23
 	 * @var \chillerlan\Traits\DotEnv|null
@@ -28,10 +28,10 @@  discard block
 block discarded – undo
28 28
 	 * @param iterable                       $properties
29 29
 	 * @param \chillerlan\Traits\DotEnv|null $env
30 30
 	 */
31
-	public function __construct(array $properties = null, DotEnv $env = null){
31
+	public function __construct(array $properties = null, DotEnv $env = null) {
32 32
 		$this->env = $env;
33 33
 
34
-		if(!empty($properties)){
34
+		if (!empty($properties)) {
35 35
 			$this->__fromIterable($properties);
36 36
 		}
37 37
 
@@ -42,12 +42,12 @@  discard block
 block discarded – undo
42 42
 	 *
43 43
 	 * @return mixed
44 44
 	 */
45
-	public function __get(string $property){
45
+	public function __get(string $property) {
46 46
 
47
-		if($this->__isset($property)){
47
+		if ($this->__isset($property)) {
48 48
 			return $this->{$property};
49 49
 		}
50
-		elseif($this->env instanceof DotEnv){
50
+		elseif ($this->env instanceof DotEnv) {
51 51
 			return $this->env->get($property);
52 52
 		}
53 53
 
@@ -60,13 +60,13 @@  discard block
 block discarded – undo
60 60
 	 *
61 61
 	 * @return void
62 62
 	 */
63
-	public function __set(string $property, $value){
63
+	public function __set(string $property, $value) {
64 64
 
65 65
 		// avoid overwriting private properties
66
-		if(property_exists($this, $property) && !$this->__isPrivate($property)){
66
+		if (property_exists($this, $property) && !$this->__isPrivate($property)) {
67 67
 			$this->{$property} = $value;
68 68
 		}
69
-		elseif($this->env instanceof DotEnv){
69
+		elseif ($this->env instanceof DotEnv) {
70 70
 			$this->env->set($property, $value);
71 71
 		}
72 72
 
@@ -95,10 +95,10 @@  discard block
 block discarded – undo
95 95
 	 *
96 96
 	 * @return void
97 97
 	 */
98
-	public function __unset(string $property){
98
+	public function __unset(string $property) {
99 99
 
100 100
 		// avoid unsetting private properties
101
-		if($this->__isset($property)){
101
+		if ($this->__isset($property)) {
102 102
 			unset($this->{$property});
103 103
 		}
104 104
 
@@ -117,10 +117,10 @@  discard block
 block discarded – undo
117 117
 	public function __toArray():array{
118 118
 		$data = [];
119 119
 
120
-		foreach($this as $property => $value){
120
+		foreach ($this as $property => $value) {
121 121
 
122 122
 			// exclude private properties
123
-			if($this->__isset($property)){
123
+			if ($this->__isset($property)) {
124 124
 				$data[$property] = $value;
125 125
 			}
126 126
 
@@ -134,9 +134,9 @@  discard block
 block discarded – undo
134 134
 	 *
135 135
 	 * @return $this
136 136
 	 */
137
-	public function __fromIterable(array $properties){
137
+	public function __fromIterable(array $properties) {
138 138
 
139
-		foreach($properties as $key => $value){
139
+		foreach ($properties as $key => $value) {
140 140
 			$this->__set($key, $value);
141 141
 		}
142 142
 
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
 	 *
156 156
 	 * @return $this
157 157
 	 */
158
-	public function __fromJSON(string $json){
158
+	public function __fromJSON(string $json) {
159 159
 		return $this->__fromIterable(json_decode($json, true));
160 160
 	}
161 161
 
Please login to merge, or discard this patch.
src/EnumerableInterface.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@
 block discarded – undo
12 12
 
13 13
 namespace chillerlan\Traits;
14 14
 
15
-interface EnumerableInterface{
15
+interface EnumerableInterface {
16 16
 
17 17
 	/**
18 18
 	 * @return array
Please login to merge, or discard this patch.
src/Enumerable.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
45 45
 	 *
46 46
 	 * @return $this
47 47
 	 */
48
-	public function __each(callable $callback){
48
+	public function __each(callable $callback) {
49 49
 		$this->__map($callback);
50 50
 
51 51
 		return $this;
@@ -62,13 +62,13 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 
@@ -90,14 +90,14 @@  discard block
 block discarded – undo
90 90
 	/**
91 91
 	 * @return mixed
92 92
 	 */
93
-	public function __last(){
93
+	public function __last() {
94 94
 		return $this->array[count($this->array) - 1];
95 95
 	}
96 96
 
97 97
 	/**
98 98
 	 * @return $this
99 99
 	 */
100
-	public function __clear(){
100
+	public function __clear() {
101 101
 		$this->array = [];
102 102
 
103 103
 		return $this;
@@ -122,15 +122,15 @@  discard block
 block discarded – undo
122 122
 	 */
123 123
 	public function __findAll(callable $callback):array{
124 124
 
125
-		if(!is_callable($callback)){
125
+		if (!is_callable($callback)) {
126 126
 			throw new TraitException('invalid callback');
127 127
 		}
128 128
 
129 129
 		$return = [];
130 130
 
131
-		foreach($this->array as $index => $element){
131
+		foreach ($this->array as $index => $element) {
132 132
 
133
-			if(call_user_func_array($callback, [$element, $index]) === true){
133
+			if (call_user_func_array($callback, [$element, $index]) === true) {
134 134
 				$return[] = $element;
135 135
 			}
136 136
 
@@ -149,15 +149,15 @@  discard block
 block discarded – undo
149 149
 	 */
150 150
 	public function __reject(callable $callback):array{
151 151
 
152
-		if(!is_callable($callback)){
152
+		if (!is_callable($callback)) {
153 153
 			throw new TraitException('invalid callback');
154 154
 		}
155 155
 
156 156
 		$return = [];
157 157
 
158
-		foreach($this->array as $index => $element){
158
+		foreach ($this->array as $index => $element) {
159 159
 
160
-			if(call_user_func_array($callback, [$element, $index]) !== true){
160
+			if (call_user_func_array($callback, [$element, $index]) !== true) {
161 161
 				$return[] = $element;
162 162
 			}
163 163
 
@@ -173,13 +173,13 @@  discard block
 block discarded – undo
173 173
 	 */
174 174
 	public function __equal(array $y):bool{
175 175
 
176
-		if(count($this->array) !== count($y)){
176
+		if (count($this->array) !== count($y)) {
177 177
 			return false;
178 178
 		}
179 179
 
180 180
 		$diff = 0;
181 181
 
182
-		foreach($this->array as $kx => $vx){
182
+		foreach ($this->array as $kx => $vx) {
183 183
 			$diff |= $vx ^ $y[$kx];
184 184
 		}
185 185
 
Please login to merge, or discard this patch.
src/ClassLoader.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 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,51 +27,51 @@  discard block
 block discarded – undo
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
 
72 72
 			return $object;
73 73
 		}
74
-		catch(Exception $e){
74
+		catch (Exception $e) {
75 75
 			throw new TraitException('ClassLoader: '.$e->getMessage());
76 76
 		}
77 77
 
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -33,8 +33,7 @@  discard block
 block discarded – undo
33 33
 		try{
34 34
 			$reflectionClass = new ReflectionClass($class);
35 35
 			$reflectionType  = new ReflectionClass($type);
36
-		}
37
-		catch(Exception $e){
36
+		} catch(Exception $e){
38 37
 			throw new TraitException('ClassLoader: '.$e->getMessage());
39 38
 		}
40 39
 
@@ -55,8 +54,7 @@  discard block
 block discarded – undo
55 54
 
56 55
 			if($reflectionType->isInterface() && !$reflectionClass->implementsInterface($type)){
57 56
 				throw new TraitException($class.' does not implement '.$type);
58
-			}
59
-			elseif(!$reflectionClass->isSubclassOf($type)) {
57
+			} elseif(!$reflectionClass->isSubclassOf($type)) {
60 58
 				throw new TraitException($class.' does not inherit '.$type);
61 59
 			}
62 60
 
@@ -70,8 +68,7 @@  discard block
 block discarded – undo
70 68
 			}
71 69
 
72 70
 			return $object;
73
-		}
74
-		catch(Exception $e){
71
+		} catch(Exception $e){
75 72
 			throw new TraitException('ClassLoader: '.$e->getMessage());
76 73
 		}
77 74
 
Please login to merge, or discard this patch.
src/ContainerAbstract.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,6 +12,6 @@
 block discarded – undo
12 12
 
13 13
 namespace chillerlan\Traits;
14 14
 
15
-abstract class ContainerAbstract implements ContainerInterface{
15
+abstract class ContainerAbstract implements ContainerInterface {
16 16
 	use Container;
17 17
 }
Please login to merge, or discard this patch.