Completed
Push — master ( 264759...40d38a )
by smiley
04:42
created
src/Enumerable.php 1 patch
Spacing   +14 added lines, -14 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($callback){
48
+	public function __each($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,21 +90,21 @@  discard block
 block discarded – undo
90 90
 	/**
91 91
 	 * @return mixed
92 92
 	 */
93
-	public function __first(){
93
+	public function __first() {
94 94
 		return $this->array[0] ?? null;
95 95
 	}
96 96
 
97 97
 	/**
98 98
 	 * @return mixed
99 99
 	 */
100
-	public function __last(){
100
+	public function __last() {
101 101
 		return $this->array[count($this->array) - 1] ?? null;
102 102
 	}
103 103
 
104 104
 	/**
105 105
 	 * @return $this
106 106
 	 */
107
-	public function __clear(){
107
+	public function __clear() {
108 108
 		$this->array = [];
109 109
 
110 110
 		return $this;
@@ -129,15 +129,15 @@  discard block
 block discarded – undo
129 129
 	 */
130 130
 	public function __findAll($callback):array{
131 131
 
132
-		if(!is_callable($callback)){
132
+		if (!is_callable($callback)) {
133 133
 			throw new TraitException('invalid callback');
134 134
 		}
135 135
 
136 136
 		$return = [];
137 137
 
138
-		foreach($this->array as $index => $element){
138
+		foreach ($this->array as $index => $element) {
139 139
 
140
-			if(call_user_func_array($callback, [$element, $index]) === true){
140
+			if (call_user_func_array($callback, [$element, $index]) === true) {
141 141
 				$return[] = $element;
142 142
 			}
143 143
 
@@ -156,15 +156,15 @@  discard block
 block discarded – undo
156 156
 	 */
157 157
 	public function __reject($callback):array{
158 158
 
159
-		if(!is_callable($callback)){
159
+		if (!is_callable($callback)) {
160 160
 			throw new TraitException('invalid callback');
161 161
 		}
162 162
 
163 163
 		$return = [];
164 164
 
165
-		foreach($this->array as $index => $element){
165
+		foreach ($this->array as $index => $element) {
166 166
 
167
-			if(call_user_func_array($callback, [$element, $index]) !== true){
167
+			if (call_user_func_array($callback, [$element, $index]) !== true) {
168 168
 				$return[] = $element;
169 169
 			}
170 170
 
Please login to merge, or discard this patch.
src/Interfaces/ArrayAccessTrait.php 1 patch
Spacing   +2 added lines, -2 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
 
Please login to merge, or discard this patch.
src/Interfaces/IteratorTrait.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
  *
19 19
  * @link http://php.net/manual/class.traversable.php
20 20
  */
21
-trait IteratorTrait{
21
+trait IteratorTrait {
22 22
 
23 23
 	/**
24 24
 	 * @var array
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 	 * @link  http://php.net/manual/iterator.current.php
35 35
 	 * @inheritdoc
36 36
 	 */
37
-	public function current(){
37
+	public function current() {
38 38
 		return $this->array[$this->offset] ?? null;
39 39
 	}
40 40
 
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 	 * @link  http://php.net/manual/iterator.key.php
51 51
 	 * @inheritdoc
52 52
 	 */
53
-	public function key(){
53
+	public function key() {
54 54
 		return $this->offset;
55 55
 	}
56 56
 
Please login to merge, or discard this patch.
src/ImmutableSettingsInterface.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 ImmutableSettingsInterface{
16
+interface ImmutableSettingsInterface {
17 17
 
18 18
 	/**
19 19
 	 * @param iterable|null $properties
Please login to merge, or discard this patch.
src/Magic.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -15,14 +15,14 @@  discard block
 block discarded – undo
15 15
 /**
16 16
  * A Container that turns methods into magic properties
17 17
  */
18
-trait Magic{
18
+trait Magic {
19 19
 
20 20
 	/**
21 21
 	 * @param string $name
22 22
 	 *
23 23
 	 * @return mixed|null
24 24
 	 */
25
-	public function __get(string $name){
25
+	public function __get(string $name) {
26 26
 		return $this->get($name);
27 27
 	}
28 28
 
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 	 *
42 42
 	 * @return mixed|null
43 43
 	 */
44
-	private function get(string $name){
44
+	private function get(string $name) {
45 45
 		$method = 'magic_get_'.$name;
46 46
 
47 47
 		return method_exists($this, $method) ? $this->$method() : null;
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 	private function set(string $name, $value):void{
57 57
 		$method = 'magic_set_'.$name;
58 58
 
59
-		if(method_exists($this, $method)){
59
+		if (method_exists($this, $method)) {
60 60
 			$this->$method($value);
61 61
 		}
62 62
 
Please login to merge, or discard this patch.
src/Env.php 1 patch
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
  * @link http://php.net/variables-order
22 22
  *
23 23
  */
24
-trait Env{
24
+trait Env {
25 25
 
26 26
 	/**
27 27
 	 * a backup environment in case everything goes downhill
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 	 *
48 48
 	 * @return $this
49 49
 	 */
50
-	protected function __loadEnv(string $path, string $filename = null, bool $overwrite = null, array $required = null, bool $global = null){
50
+	protected function __loadEnv(string $path, string $filename = null, bool $overwrite = null, array $required = null, bool $global = null) {
51 51
 		$this->_global = $global ?? false;
52 52
 		$content       = $this->__read(rtrim($path, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.($filename ?? '.env'));
53 53
 
@@ -62,20 +62,20 @@  discard block
 block discarded – undo
62 62
 	 *
63 63
 	 * @return bool|mixed
64 64
 	 */
65
-	protected function __getEnv(string $var){
65
+	protected function __getEnv(string $var) {
66 66
 		$var = strtoupper($var);
67 67
 		$env = null;
68 68
 
69
-		if($this->_global === true){
69
+		if ($this->_global === true) {
70 70
 
71
-			if(array_key_exists($var, $_ENV)){
71
+			if (array_key_exists($var, $_ENV)) {
72 72
 				$env = $_ENV[$var];
73 73
 			}
74
-			elseif(function_exists('getenv')){
74
+			elseif (function_exists('getenv')) {
75 75
 				$env = getenv($var);
76 76
 			}
77 77
 			// @codeCoverageIgnoreStart
78
-			elseif(function_exists('apache_getenv')){
78
+			elseif (function_exists('apache_getenv')) {
79 79
 				/** @noinspection PhpComposerExtensionStubsInspection */
80 80
 				$env = apache_getenv($var);
81 81
 			}
@@ -92,18 +92,18 @@  discard block
 block discarded – undo
92 92
 	 *
93 93
 	 * @return $this
94 94
 	 */
95
-	protected function __setEnv(string $var, string $value = null){
95
+	protected function __setEnv(string $var, string $value = null) {
96 96
 		$var   = strtoupper($var);
97 97
 		$value = $this->__parse($value);
98 98
 
99
-		if($this->_global === true){
99
+		if ($this->_global === true) {
100 100
 			putenv($var.'='.$value);
101 101
 
102 102
 			// fill $_ENV explicitly, assuming variables_order="GPCS" (production)
103 103
 			$_ENV[$var] = $value;
104 104
 
105 105
 			// @codeCoverageIgnoreStart
106
-			if(function_exists('apache_setenv')){
106
+			if (function_exists('apache_setenv')) {
107 107
 				/** @noinspection PhpComposerExtensionStubsInspection */
108 108
 				apache_setenv($var, $value);
109 109
 			}
@@ -136,10 +136,10 @@  discard block
 block discarded – undo
136 136
 	 *
137 137
 	 * @return $this
138 138
 	 */
139
-	protected function __unsetEnv(string $var){
139
+	protected function __unsetEnv(string $var) {
140 140
 		$var = strtoupper($var);
141 141
 
142
-		if($this->_global === true){
142
+		if ($this->_global === true) {
143 143
 			unset($_ENV[$var]);
144 144
 			putenv($var);
145 145
 		}
@@ -154,9 +154,9 @@  discard block
 block discarded – undo
154 154
 	 *
155 155
 	 * @return $this
156 156
 	 */
157
-	protected function __clearEnv(){
157
+	protected function __clearEnv() {
158 158
 
159
-		if($this->_global === true){
159
+		if ($this->_global === true) {
160 160
 			$_ENV = [];
161 161
 		}
162 162
 
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
 	 */
174 174
 	private function __read(string $file):array{
175 175
 
176
-		if(!is_readable($file) || !is_file($file)){
176
+		if (!is_readable($file) || !is_file($file)) {
177 177
 			throw new TraitException('invalid file: '.$file);
178 178
 		}
179 179
 
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 		$lines = file($file, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
184 184
 		ini_set('auto_detect_line_endings', $autodetect);
185 185
 
186
-		if(!is_array($lines) || empty($lines)){
186
+		if (!is_array($lines) || empty($lines)) {
187 187
 			throw new TraitException('error while reading file: '.$file);
188 188
 		}
189 189
 
@@ -196,19 +196,19 @@  discard block
 block discarded – undo
196 196
 	 *
197 197
 	 * @return $this
198 198
 	 */
199
-	private function __load(array $data, bool $overwrite){
199
+	private function __load(array $data, bool $overwrite) {
200 200
 
201
-		foreach($data as $line){
201
+		foreach ($data as $line) {
202 202
 
203 203
 			// skip empty lines and comments
204
-			if(empty($line) || strpos($line, '#') === 0){
204
+			if (empty($line) || strpos($line, '#') === 0) {
205 205
 				continue;
206 206
 			}
207 207
 
208 208
 			$kv = array_map('trim', explode('=', $line, 2));
209 209
 
210 210
 			// skip empty and numeric keys, keys with spaces, existing keys that shall not be overwritten
211
-			if(empty($kv[0]) || is_numeric($kv[0]) || strpos($kv[0], ' ') !== false || (!$overwrite && $this->__getEnv($kv[0]) !== false)){
211
+			if (empty($kv[0]) || is_numeric($kv[0]) || strpos($kv[0], ' ') !== false || (!$overwrite && $this->__getEnv($kv[0]) !== false)) {
212 212
 				continue;
213 213
 			}
214 214
 
@@ -223,9 +223,9 @@  discard block
 block discarded – undo
223 223
 	 *
224 224
 	 * @return string|null
225 225
 	 */
226
-	private function __parse(string $value = null):?string{
226
+	private function __parse(string $value = null): ?string{
227 227
 
228
-		if($value !== null){
228
+		if ($value !== null) {
229 229
 
230 230
 			$q = $value[0] ?? null;
231 231
 
@@ -239,8 +239,8 @@  discard block
 block discarded – undo
239 239
 			$value = implode(PHP_EOL, explode('\\n', $value));
240 240
 
241 241
 			// handle nested ${VARS}
242
-			if(strpos($value, '$') !== false){
243
-				$value = preg_replace_callback('/\${(?<var>[_a-z\d]+)}/i', function($matches){
242
+			if (strpos($value, '$') !== false) {
243
+				$value = preg_replace_callback('/\${(?<var>[_a-z\d]+)}/i', function($matches) {
244 244
 					return $this->__getEnv($matches['var']);
245 245
 				}, $value);
246 246
 			}
@@ -256,14 +256,14 @@  discard block
 block discarded – undo
256 256
 	 * @return $this
257 257
 	 * @throws \chillerlan\Traits\TraitException
258 258
 	 */
259
-	private function __check(array $required = null){
259
+	private function __check(array $required = null) {
260 260
 
261
-		if($required === null || empty($required)){
261
+		if ($required === null || empty($required)) {
262 262
 			return $this;
263 263
 		}
264 264
 
265
-		foreach($required as $var){
266
-			if(!$this->__issetEnv($var)){
265
+		foreach ($required as $var) {
266
+			if (!$this->__issetEnv($var)) {
267 267
 				throw new TraitException('required variable not set: '.strtoupper($var));
268 268
 			}
269 269
 		}
Please login to merge, or discard this patch.
src/ImmutableSettingsAbstract.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 ImmutableSettingsAbstract implements ImmutableSettingsInterface{
15
+abstract class ImmutableSettingsAbstract implements ImmutableSettingsInterface {
16 16
 	use ImmutableSettingsContainer;
17 17
 }
Please login to merge, or discard this patch.
src/Crypto/CryptoKeypair.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -45,9 +45,9 @@
 block discarded – undo
45 45
 	 *
46 46
 	 * @throws \chillerlan\Traits\Crypto\CryptoException
47 47
 	 */
48
-	public function __construct(iterable $properties = null){
48
+	public function __construct(iterable $properties = null) {
49 49
 
50
-		if(!extension_loaded('sodium') || !function_exists('sodium_memzero')){
50
+		if (!extension_loaded('sodium') || !function_exists('sodium_memzero')) {
51 51
 			throw new CryptoException('sodium extension (PHP 7.2+) required!'); // @codeCoverageIgnore
52 52
 		}
53 53
 
Please login to merge, or discard this patch.
src/Crypto/CryptoBox.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -53,9 +53,9 @@  discard block
 block discarded – undo
53 53
 	 *
54 54
 	 * @throws \chillerlan\Traits\Crypto\CryptoException
55 55
 	 */
56
-	public function __construct(iterable $properties = null){
56
+	public function __construct(iterable $properties = null) {
57 57
 
58
-		if(!extension_loaded('sodium') || !function_exists('sodium_memzero')){
58
+		if (!extension_loaded('sodium') || !function_exists('sodium_memzero')) {
59 59
 			throw new CryptoException('sodium extension (PHP 7.2+) required!'); // @codeCoverageIgnore
60 60
 		}
61 61
 
@@ -71,14 +71,14 @@  discard block
 block discarded – undo
71 71
 	 */
72 72
 	protected function checkKeypair(int $secretLength = null, int $PublicLength = null):void{
73 73
 
74
-		if($secretLength !== null){
75
-			if(!$this->keypair->secret || strlen($this->keypair->secret) !== $secretLength){
74
+		if ($secretLength !== null) {
75
+			if (!$this->keypair->secret || strlen($this->keypair->secret) !== $secretLength) {
76 76
 				throw new CryptoException('invalid secret key');
77 77
 			}
78 78
 		}
79 79
 
80
-		if($PublicLength !== null){
81
-			if(!$this->keypair->public || strlen($this->keypair->public) !== $PublicLength){
80
+		if ($PublicLength !== null) {
81
+			if (!$this->keypair->public || strlen($this->keypair->public) !== $PublicLength) {
82 82
 				throw new CryptoException('invalid public key');
83 83
 			}
84 84
 		}
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
 	protected function checkMessage(string $message):string{
95 95
 		$message = trim($message);
96 96
 
97
-		if(empty($message)){
97
+		if (empty($message)) {
98 98
 			throw new CryptoException('invalid message');
99 99
 		}
100 100
 
Please login to merge, or discard this patch.