@@ -3,5 +3,5 @@ |
||
3 | 3 | return [ |
4 | 4 | 'default' => 'bcrypt', |
5 | 5 | |
6 | - 'bcrypt' => [] |
|
6 | + 'bcrypt' => [ ] |
|
7 | 7 | ]; |
@@ -79,7 +79,9 @@ |
||
79 | 79 | function getStringBetween($string, $start, $end) { |
80 | 80 | $string = ' ' . $string; |
81 | 81 | $ini = strpos($string, $start); |
82 | - if ($ini == 0) return ''; |
|
82 | + if ($ini == 0) { |
|
83 | + return ''; |
|
84 | + } |
|
83 | 85 | $ini += strlen($start); |
84 | 86 | $len = strpos($string, $end, $ini) - $ini; |
85 | 87 | return substr($string, $ini, $len); |
@@ -1,15 +1,15 @@ discard block |
||
1 | 1 | <?php |
2 | -if(! function_exists("dd")) { |
|
2 | +if (!function_exists("dd")) { |
|
3 | 3 | /** |
4 | 4 | * Little helper called dump and die |
5 | 5 | * @param $val |
6 | 6 | */ |
7 | 7 | function dd($val) { |
8 | - \app\framework\Component\VarDumper\VarDumper::dump($val);die; |
|
8 | + \app\framework\Component\VarDumper\VarDumper::dump($val); die; |
|
9 | 9 | } |
10 | 10 | } |
11 | 11 | |
12 | -if(! function_exists("pathTo")) { |
|
12 | +if (!function_exists("pathTo")) { |
|
13 | 13 | /** |
14 | 14 | * Easy function to get the path to the project + if you want an directory in it. |
15 | 15 | * |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | } |
22 | 22 | } |
23 | 23 | |
24 | -if(! function_exists("view")) { |
|
24 | +if (!function_exists("view")) { |
|
25 | 25 | /** |
26 | 26 | * Get the evaluated view contents for the given view. |
27 | 27 | * |
@@ -29,14 +29,14 @@ discard block |
||
29 | 29 | * @param array $data Data to set values in template file |
30 | 30 | * @return \app\framework\Component\View\View|string |
31 | 31 | */ |
32 | - function view($view = null, $data = []) { |
|
33 | - $data['auth'] = new \app\framework\Component\Auth\Auth; |
|
32 | + function view($view = null, $data = [ ]) { |
|
33 | + $data[ 'auth' ] = new \app\framework\Component\Auth\Auth; |
|
34 | 34 | $View = new \app\framework\Component\View\View($view, $data); |
35 | 35 | return $View->render(); |
36 | 36 | } |
37 | 37 | } |
38 | 38 | |
39 | -if(! function_exists("app")) { |
|
39 | +if (!function_exists("app")) { |
|
40 | 40 | /** |
41 | 41 | * Used to easily call Methods from classes without manually set |
42 | 42 | * locally Instances of them. |
@@ -45,23 +45,23 @@ discard block |
||
45 | 45 | * @param array $param To declare what parameter shall be passed to the method |
46 | 46 | * @return mixed |
47 | 47 | */ |
48 | - function app($classMethod, $param = []) { |
|
49 | - return $GLOBALS["App"]->call($classMethod, $param); |
|
48 | + function app($classMethod, $param = [ ]) { |
|
49 | + return $GLOBALS[ "App" ]->call($classMethod, $param); |
|
50 | 50 | } |
51 | 51 | } |
52 | 52 | |
53 | -if(! function_exists("url")) { |
|
53 | +if (!function_exists("url")) { |
|
54 | 54 | /** |
55 | 55 | * Returns UrlObject with current url |
56 | 56 | * |
57 | 57 | * @return \app\framework\Component\StdLib\StdObject\UrlObject\UrlObject |
58 | 58 | */ |
59 | 59 | function url() { |
60 | - return new \app\framework\Component\StdLib\StdObject\UrlObject\UrlObject($_SERVER['HTTP_HOST']); |
|
60 | + return new \app\framework\Component\StdLib\StdObject\UrlObject\UrlObject($_SERVER[ 'HTTP_HOST' ]); |
|
61 | 61 | } |
62 | 62 | } |
63 | 63 | |
64 | -if(! function_exists("getStringBetween")) { |
|
64 | +if (!function_exists("getStringBetween")) { |
|
65 | 65 | /** |
66 | 66 | * This is a handy little function to strip out a string between |
67 | 67 | * two specified pieces of text. This could be used to parse |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | * @return bool|string |
74 | 74 | */ |
75 | 75 | function getStringBetween($string, $start, $end) { |
76 | - $string = ' ' . $string; |
|
76 | + $string = ' '.$string; |
|
77 | 77 | $ini = strpos($string, $start); |
78 | 78 | if ($ini == 0) return ''; |
79 | 79 | $ini += strlen($start); |
@@ -82,31 +82,31 @@ discard block |
||
82 | 82 | } |
83 | 83 | } |
84 | 84 | |
85 | -if(! function_exists("handle")) { |
|
86 | - function handle( $e) { |
|
85 | +if (!function_exists("handle")) { |
|
86 | + function handle($e) { |
|
87 | 87 | \app\framework\Component\Exception\Handler::getInstance()->handler($e); |
88 | 88 | } |
89 | 89 | } |
90 | 90 | |
91 | -if(! function_exists("arr")) { |
|
91 | +if (!function_exists("arr")) { |
|
92 | 92 | /** |
93 | 93 | * Create an ArrayObject from array |
94 | 94 | * |
95 | 95 | * @param array $arr |
96 | 96 | * @return \app\framework\Component\StdLib\StdObject\ArrayObject\ArrayObject |
97 | 97 | */ |
98 | - function arr(array $arr = []) { |
|
98 | + function arr(array $arr = [ ]) { |
|
99 | 99 | return new \app\framework\Component\StdLib\StdObject\ArrayObject\ArrayObject($arr); |
100 | 100 | } |
101 | 101 | } |
102 | 102 | |
103 | -if(! function_exists("str")) { |
|
103 | +if (!function_exists("str")) { |
|
104 | 104 | function str($str) { |
105 | 105 | return new \app\framework\Component\StdLib\StdObject\StringObject\StringObject($str); |
106 | 106 | } |
107 | 107 | } |
108 | 108 | |
109 | -if(! function_exists("encrypt")) { |
|
109 | +if (!function_exists("encrypt")) { |
|
110 | 110 | /** |
111 | 111 | * Encrypt the given value. |
112 | 112 | * |
@@ -120,11 +120,11 @@ discard block |
||
120 | 120 | \app\framework\Component\Config\Config::getInstance()->get("CrypKey") |
121 | 121 | ); |
122 | 122 | |
123 | - return $Encryptor->encrypt($value, $serialize ); |
|
123 | + return $Encryptor->encrypt($value, $serialize); |
|
124 | 124 | } |
125 | 125 | } |
126 | 126 | |
127 | -if(! function_exists("decrypt")) { |
|
127 | +if (!function_exists("decrypt")) { |
|
128 | 128 | /** |
129 | 129 | * Decrypt the given value. |
130 | 130 | * |
@@ -138,11 +138,11 @@ discard block |
||
138 | 138 | \app\framework\Component\Config\Config::getInstance()->get("CrypKey") |
139 | 139 | ); |
140 | 140 | |
141 | - return $Encryptor->decrypt($value, $unserialize ); |
|
141 | + return $Encryptor->decrypt($value, $unserialize); |
|
142 | 142 | } |
143 | 143 | } |
144 | 144 | |
145 | -if(! function_exists("version")) { |
|
145 | +if (!function_exists("version")) { |
|
146 | 146 | /** |
147 | 147 | * @return string version as written in config/app.php |
148 | 148 | */ |
@@ -151,13 +151,13 @@ discard block |
||
151 | 151 | } |
152 | 152 | } |
153 | 153 | |
154 | -if(! function_exists("isDebug")) { |
|
154 | +if (!function_exists("isDebug")) { |
|
155 | 155 | function isDebug() { |
156 | 156 | return \app\framework\Component\Config\Config::getInstance()->get("debug", "app"); |
157 | 157 | } |
158 | 158 | } |
159 | 159 | |
160 | -if(! function_exists("class_basename")) { |
|
160 | +if (!function_exists("class_basename")) { |
|
161 | 161 | /** |
162 | 162 | * Get the class "basename" of the given object / class. |
163 | 163 | * |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | } |
172 | 172 | } |
173 | 173 | |
174 | -if (! function_exists("get_connection_log")) |
|
174 | +if (!function_exists("get_connection_log")) |
|
175 | 175 | { |
176 | 176 | /** |
177 | 177 | * returns query log from Connection as array |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | } |
186 | 186 | } |
187 | 187 | |
188 | -if (! function_exists("datetime")) { |
|
188 | +if (!function_exists("datetime")) { |
|
189 | 189 | /** |
190 | 190 | * @param string $time |
191 | 191 | * @param null $timezone |
@@ -20,6 +20,6 @@ |
||
20 | 20 | |
21 | 21 | include("helper.php"); |
22 | 22 | |
23 | -if(isDebug()) { |
|
23 | +if (isDebug()) { |
|
24 | 24 | set_exception_handler("handle"); |
25 | 25 | } |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | */ |
19 | 19 | class Config |
20 | 20 | { |
21 | - use StdLibTrait,SingletonTrait; |
|
21 | + use StdLibTrait, SingletonTrait; |
|
22 | 22 | |
23 | 23 | private $data; |
24 | 24 | |
@@ -26,14 +26,14 @@ discard block |
||
26 | 26 | { |
27 | 27 | $this->getAllData(); |
28 | 28 | //var_dump($this->data->val()); |
29 | - if(!$this->isNull($file)){ |
|
29 | + if (!$this->isNull($file)) { |
|
30 | 30 | $file = $this->arr($this->data->key($file)); |
31 | 31 | |
32 | 32 | return $file->key($config); |
33 | 33 | } else { |
34 | - foreach($this->data->val() as $confCont){ |
|
34 | + foreach ($this->data->val() as $confCont) { |
|
35 | 35 | $confCont = $this->arr($confCont); |
36 | - if($confCont->keyExists($config)){ |
|
36 | + if ($confCont->keyExists($config)) { |
|
37 | 37 | return $confCont->key($config); |
38 | 38 | } |
39 | 39 | } |
@@ -47,8 +47,8 @@ discard block |
||
47 | 47 | $files = $this->arr(scandir(ROOT_PATH.DIRECTORY_SEPARATOR."config".DIRECTORY_SEPARATOR)); |
48 | 48 | $files->removeFirst()->removeFirst(); |
49 | 49 | |
50 | - foreach($files->val() as $file){ |
|
51 | - $temp[explode(".", $file)[0]] = include( |
|
50 | + foreach ($files->val() as $file) { |
|
51 | + $temp[ explode(".", $file)[ 0 ] ] = include( |
|
52 | 52 | ROOT_PATH.DIRECTORY_SEPARATOR."config".DIRECTORY_SEPARATOR.$file |
53 | 53 | ); |
54 | 54 | } |
@@ -33,5 +33,5 @@ |
||
33 | 33 | * @return boolean|string |
34 | 34 | * @throws ValidationException |
35 | 35 | */ |
36 | - public function validate($value, $params = [], $throw = true); |
|
36 | + public function validate($value, $params = [ ], $throw = true); |
|
37 | 37 | } |
@@ -39,12 +39,12 @@ |
||
39 | 39 | private $validators = []; |
40 | 40 | |
41 | 41 | /** |
42 | - * @param mixed $data |
|
43 | - * @param string|array $validators |
|
44 | - * @param bool|true $throw |
|
45 | - * |
|
46 | - * @return bool |
|
47 | - */ |
|
42 | + * @param mixed $data |
|
43 | + * @param string|array $validators |
|
44 | + * @param bool|true $throw |
|
45 | + * |
|
46 | + * @return bool |
|
47 | + */ |
|
48 | 48 | public function validate($data, $validators, $throw = true) |
49 | 49 | { |
50 | 50 | $validators = $this->getValidators($validators); |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | { |
37 | 37 | use SingletonTrait; |
38 | 38 | |
39 | - private $validators = []; |
|
39 | + private $validators = [ ]; |
|
40 | 40 | |
41 | 41 | /** |
42 | 42 | * @param mixed $data |
@@ -57,10 +57,10 @@ discard block |
||
57 | 57 | $throw |
58 | 58 | ]; |
59 | 59 | |
60 | - if (!array_key_exists($validator[0], $this->validators)) { |
|
61 | - handle(new ValidationException('Validator %s does not exist!', $validator[0])); |
|
60 | + if (!array_key_exists($validator[ 0 ], $this->validators)) { |
|
61 | + handle(new ValidationException('Validator %s does not exist!', $validator[ 0 ])); |
|
62 | 62 | } |
63 | - $res = $this->validators[$validator[0]]->validate(...$functionParams); |
|
63 | + $res = $this->validators[ $validator[ 0 ] ]->validate(...$functionParams); |
|
64 | 64 | |
65 | 65 | // If validation failed and we are not throwing, return error message string |
66 | 66 | if ($res !== true && !$throw) { |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | */ |
81 | 81 | public function addValidator(ValidatorInterface $validator) |
82 | 82 | { |
83 | - $this->validators[$validator->getName()] = $validator; |
|
83 | + $this->validators[ $validator->getName() ] = $validator; |
|
84 | 84 | |
85 | 85 | return $this; |
86 | 86 | } |
@@ -108,8 +108,8 @@ discard block |
||
108 | 108 | ]; |
109 | 109 | |
110 | 110 | /* @var $v ValidatorInterface */ |
111 | - foreach($buildInValidators as $v){ |
|
112 | - $this->validators[$v->getName()] = $v; |
|
111 | + foreach ($buildInValidators as $v) { |
|
112 | + $this->validators[ $v->getName() ] = $v; |
|
113 | 113 | } |
114 | 114 | } |
115 | 115 | |
@@ -123,6 +123,6 @@ discard block |
||
123 | 123 | return explode(',', $validators); |
124 | 124 | } |
125 | 125 | |
126 | - return []; |
|
126 | + return [ ]; |
|
127 | 127 | } |
128 | 128 | } |
@@ -18,9 +18,9 @@ |
||
18 | 18 | return 'password'; |
19 | 19 | } |
20 | 20 | |
21 | - public function validate($value, $params = [], $throw = false) |
|
21 | + public function validate($value, $params = [ ], $throw = false) |
|
22 | 22 | { |
23 | - $isDevPassword = in_array($value, ['dev', 'admin']); |
|
23 | + $isDevPassword = in_array($value, [ 'dev', 'admin' ]); |
|
24 | 24 | $isFullyValid = preg_match_all("/^.*(?=.{8,})(?=.*[a-zA-Z])(?=.*\\d).*$/", $value); |
25 | 25 | |
26 | 26 | if ($isDevPassword || $isFullyValid) { |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | { |
172 | 172 | $this->init(); |
173 | 173 | |
174 | - return isset($this->commands[$name]) || $this->commandLoader->has($name); |
|
174 | + return isset($this->commands[ $name ]) || $this->commandLoader->has($name); |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | /** |
@@ -187,12 +187,12 @@ discard block |
||
187 | 187 | { |
188 | 188 | $this->init(); |
189 | 189 | |
190 | - if(!$this->has($name) && $this->commandLoader->has($name)) { |
|
190 | + if (!$this->has($name) && $this->commandLoader->has($name)) { |
|
191 | 191 | throw new CommandNotFoundException(sprintf('The command "%s" does not exist.', $name)); |
192 | 192 | } |
193 | 193 | |
194 | - if(isset($this->commands[$name])) { |
|
195 | - return $this->commands[$name]; |
|
194 | + if (isset($this->commands[ $name ])) { |
|
195 | + return $this->commands[ $name ]; |
|
196 | 196 | } |
197 | 197 | |
198 | 198 | return $this->commandLoader->get($name); |
@@ -278,8 +278,8 @@ discard block |
||
278 | 278 | |
279 | 279 | $commands = array(); |
280 | 280 | foreach ($this->commandLoader->getNames() as $name) { |
281 | - if (!isset($commands[$name]) && $this->has($name)) { |
|
282 | - $commands[$name] = $this->get($name); |
|
281 | + if (!isset($commands[ $name ]) && $this->has($name)) { |
|
282 | + $commands[ $name ] = $this->get($name); |
|
283 | 283 | } |
284 | 284 | } |
285 | 285 | |
@@ -289,20 +289,20 @@ discard block |
||
289 | 289 | $commands = array(); |
290 | 290 | foreach ($this->commands as $name => $command) { |
291 | 291 | if ($namespace === $this->extractNamespace($name, substr_count($namespace, ':') + 1)) { |
292 | - $commands[$name] = $command; |
|
292 | + $commands[ $name ] = $command; |
|
293 | 293 | } |
294 | 294 | } |
295 | 295 | |
296 | 296 | if ($this->commandLoader) { |
297 | 297 | foreach ($this->commandLoader->getNames() as $name) { |
298 | - if (!isset($commands[$name]) |
|
298 | + if (!isset($commands[ $name ]) |
|
299 | 299 | && $namespace === $this->extractNamespace( |
300 | 300 | $name, |
301 | 301 | substr_count($namespace, ':') + 1 |
302 | 302 | ) |
303 | 303 | && $this->has($name) |
304 | 304 | ) { |
305 | - $commands[$name] = $this->get($name); |
|
305 | + $commands[ $name ] = $this->get($name); |
|
306 | 306 | } |
307 | 307 | } |
308 | 308 | } |
@@ -342,12 +342,12 @@ discard block |
||
342 | 342 | $allNamespaces = $this->getNamespaces(); |
343 | 343 | $expr = preg_replace_callback( |
344 | 344 | '{([^:]+|)}', |
345 | - function ($matches) { |
|
346 | - return preg_quote($matches[1]).'[^:]*'; |
|
345 | + function($matches) { |
|
346 | + return preg_quote($matches[ 1 ]).'[^:]*'; |
|
347 | 347 | }, |
348 | 348 | $namespace |
349 | 349 | ); |
350 | - $namespaces = preg_grep('{^'.$expr.'}', $allNamespaces); |
|
350 | + $namespaces = preg_grep('{^'.$expr.'}', $allNamespaces); |
|
351 | 351 | |
352 | 352 | if (empty($namespaces)) { |
353 | 353 | $message = sprintf('There are no commands defined in the "%s" namespace.', $namespace); |
@@ -462,29 +462,29 @@ discard block |
||
462 | 462 | */ |
463 | 463 | private function getDefaultCommands() |
464 | 464 | { |
465 | - $classes = []; |
|
465 | + $classes = [ ]; |
|
466 | 466 | $excludeClass = "app\\framework\\Component\\Console\\Command\\Command"; |
467 | 467 | |
468 | 468 | // Go through all registered namespaces and get all classes inside. |
469 | 469 | // Create instance of classes and put it in array if |
470 | 470 | // its not the Command class and its an instance of it. |
471 | 471 | foreach ($this->defaultNamespaces as $namespace) { |
472 | - $path = str_replace("\\","/", $namespace); |
|
472 | + $path = str_replace("\\", "/", $namespace); |
|
473 | 473 | $filesInNamespace = new ArrayObject(scandir(ROOT_PATH."/".$path."/")); |
474 | 474 | $filesInNamespace->removeFirst()->removeFirst(); |
475 | 475 | |
476 | - for ($i = 0; $i <= $filesInNamespace->count()-1; $i++) { |
|
477 | - $filesInNamespace->key($i, explode(".php", $filesInNamespace->key($i))[0]); |
|
476 | + for ($i = 0; $i <= $filesInNamespace->count() - 1; $i++) { |
|
477 | + $filesInNamespace->key($i, explode(".php", $filesInNamespace->key($i))[ 0 ]); |
|
478 | 478 | } |
479 | 479 | |
480 | 480 | foreach ($filesInNamespace->val() as $value) { |
481 | 481 | $class = $namespace.$value; |
482 | - if( |
|
482 | + if ( |
|
483 | 483 | class_exists($class) |
484 | 484 | && $class != $excludeClass |
485 | 485 | && is_subclass_of($class, $excludeClass) |
486 | 486 | ) |
487 | - $classes[] = new $class(); |
|
487 | + $classes[ ] = new $class(); |
|
488 | 488 | } |
489 | 489 | } |
490 | 490 | |
@@ -523,9 +523,9 @@ discard block |
||
523 | 523 | |
524 | 524 | foreach ($parts as $part) { |
525 | 525 | if (count($namespaces)) { |
526 | - $namespaces[] = end($namespaces).':'.$part; |
|
526 | + $namespaces[ ] = end($namespaces).':'.$part; |
|
527 | 527 | } else { |
528 | - $namespaces[] = $part; |
|
528 | + $namespaces[ ] = $part; |
|
529 | 529 | } |
530 | 530 | } |
531 | 531 | |
@@ -548,30 +548,30 @@ discard block |
||
548 | 548 | $collectionParts = array(); |
549 | 549 | |
550 | 550 | foreach ($collection as $item) { |
551 | - $collectionParts[$item] = explode(':', $item); |
|
551 | + $collectionParts[ $item ] = explode(':', $item); |
|
552 | 552 | } |
553 | 553 | |
554 | 554 | foreach (explode(':', $name) as $i => $subname) { |
555 | 555 | foreach ($collectionParts as $collectionName => $parts) { |
556 | - $exists = isset($alternatives[$collectionName]); |
|
556 | + $exists = isset($alternatives[ $collectionName ]); |
|
557 | 557 | |
558 | - if (!isset($parts[$i]) && $exists) { |
|
559 | - $alternatives[$collectionName] += $threshold; |
|
558 | + if (!isset($parts[ $i ]) && $exists) { |
|
559 | + $alternatives[ $collectionName ] += $threshold; |
|
560 | 560 | continue; |
561 | - } elseif (!isset($parts[$i])) { |
|
561 | + } elseif (!isset($parts[ $i ])) { |
|
562 | 562 | continue; |
563 | 563 | } |
564 | 564 | |
565 | - $lev = levenshtein($subname, $parts[$i]); |
|
565 | + $lev = levenshtein($subname, $parts[ $i ]); |
|
566 | 566 | |
567 | 567 | if ($lev <= strlen($subname) / 3 || '' !== $subname |
568 | - && false !== strpos($parts[$i], $subname) |
|
568 | + && false !== strpos($parts[ $i ], $subname) |
|
569 | 569 | ) { |
570 | - $alternatives[$collectionName] = $exists |
|
571 | - ? $alternatives[$collectionName] + $lev |
|
570 | + $alternatives[ $collectionName ] = $exists |
|
571 | + ? $alternatives[ $collectionName ] + $lev |
|
572 | 572 | : $lev; |
573 | 573 | } elseif ($exists) { |
574 | - $alternatives[$collectionName] += $threshold; |
|
574 | + $alternatives[ $collectionName ] += $threshold; |
|
575 | 575 | } |
576 | 576 | } |
577 | 577 | } |
@@ -580,11 +580,11 @@ discard block |
||
580 | 580 | $lev = levenshtein($name, $item); |
581 | 581 | |
582 | 582 | if ($lev <= strlen($name) / 3 || false !== strpos($item, $name)) { |
583 | - $alternatives[$item] = isset($alternatives[$item]) ? $alternatives[$item] - $lev : $lev; |
|
583 | + $alternatives[ $item ] = isset($alternatives[ $item ]) ? $alternatives[ $item ] - $lev : $lev; |
|
584 | 584 | } |
585 | 585 | } |
586 | 586 | |
587 | - $alternatives = array_filter($alternatives, function ($lev) use ($threshold) { |
|
587 | + $alternatives = array_filter($alternatives, function($lev) use ($threshold) { |
|
588 | 588 | return $lev < 2 * $threshold; |
589 | 589 | }); |
590 | 590 | ksort($alternatives, SORT_NATURAL | SORT_FLAG_CASE); |
@@ -614,11 +614,11 @@ discard block |
||
614 | 614 | } |
615 | 615 | |
616 | 616 | // if not, push current line to array and make new line |
617 | - $lines[] = str_pad($line, $width); |
|
617 | + $lines[ ] = str_pad($line, $width); |
|
618 | 618 | $line = $char; |
619 | 619 | } |
620 | 620 | |
621 | - $lines[] = count($lines) ? str_pad($line, $width) : $line; |
|
621 | + $lines[ ] = count($lines) ? str_pad($line, $width) : $line; |
|
622 | 622 | mb_convert_variables($encoding, 'utf8', $lines); |
623 | 623 | |
624 | 624 | return $lines; |
@@ -653,7 +653,7 @@ discard block |
||
653 | 653 | foreach ($this->splitStringByWidth($line, $width - 4) as $line) { |
654 | 654 | // pre-format lines to get the right string length |
655 | 655 | $lineLength = Helper::strlen($line) + 4; |
656 | - $lines[] = array($line, $lineLength); |
|
656 | + $lines[ ] = array($line, $lineLength); |
|
657 | 657 | $len = max($lineLength, $len); |
658 | 658 | } |
659 | 659 | } |
@@ -663,7 +663,7 @@ discard block |
||
663 | 663 | if (!$e instanceof ExceptionInterface |
664 | 664 | || OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) |
665 | 665 | { |
666 | - $messages[] = sprintf( |
|
666 | + $messages[ ] = sprintf( |
|
667 | 667 | '<comment>%s</comment>', |
668 | 668 | OutputFormatter::escape( |
669 | 669 | sprintf( |
@@ -675,10 +675,10 @@ discard block |
||
675 | 675 | ); |
676 | 676 | } |
677 | 677 | |
678 | - $messages[] = $emptyLine = sprintf('<error>%s</error>', str_repeat(' ', $len)); |
|
678 | + $messages[ ] = $emptyLine = sprintf('<error>%s</error>', str_repeat(' ', $len)); |
|
679 | 679 | |
680 | 680 | if ('' === $message || OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) { |
681 | - $messages[] = sprintf( |
|
681 | + $messages[ ] = sprintf( |
|
682 | 682 | '<error>%s%s</error>', |
683 | 683 | $title, str_repeat( |
684 | 684 | ' ', |
@@ -688,15 +688,15 @@ discard block |
||
688 | 688 | } |
689 | 689 | |
690 | 690 | foreach ($lines as $line) { |
691 | - $messages[] = sprintf( |
|
691 | + $messages[ ] = sprintf( |
|
692 | 692 | '<error> %s %s</error>', |
693 | - OutputFormatter::escape($line[0]), |
|
694 | - str_repeat(' ', $len - $line[1]) |
|
693 | + OutputFormatter::escape($line[ 0 ]), |
|
694 | + str_repeat(' ', $len - $line[ 1 ]) |
|
695 | 695 | ); |
696 | 696 | } |
697 | 697 | |
698 | - $messages[] = $emptyLine; |
|
699 | - $messages[] = ''; |
|
698 | + $messages[ ] = $emptyLine; |
|
699 | + $messages[ ] = ''; |
|
700 | 700 | $output->writeln($messages, OutputInterface::VERBOSITY_QUIET); |
701 | 701 | |
702 | 702 | if (OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) { |
@@ -708,11 +708,11 @@ discard block |
||
708 | 708 | $trace = $e->getTrace(); |
709 | 709 | |
710 | 710 | for ($i = 0, $count = count($trace); $i < $count; ++$i) { |
711 | - $class = isset($trace[$i]['class']) ? $trace[$i]['class'] : ''; |
|
712 | - $type = isset($trace[$i]['type']) ? $trace[$i]['type'] : ''; |
|
713 | - $function = $trace[$i]['function']; |
|
714 | - $file = isset($trace[$i]['file']) ? $trace[$i]['file'] : 'n/a'; |
|
715 | - $line = isset($trace[$i]['line']) ? $trace[$i]['line'] : 'n/a'; |
|
711 | + $class = isset($trace[ $i ][ 'class' ]) ? $trace[ $i ][ 'class' ] : ''; |
|
712 | + $type = isset($trace[ $i ][ 'type' ]) ? $trace[ $i ][ 'type' ] : ''; |
|
713 | + $function = $trace[ $i ][ 'function' ]; |
|
714 | + $file = isset($trace[ $i ][ 'file' ]) ? $trace[ $i ][ 'file' ] : 'n/a'; |
|
715 | + $line = isset($trace[ $i ][ 'line' ]) ? $trace[ $i ][ 'line' ] : 'n/a'; |
|
716 | 716 | $output->writeln( |
717 | 717 | sprintf( |
718 | 718 | ' %s%s%s() at <info>%s:%s</info>', |
@@ -797,8 +797,8 @@ discard block |
||
797 | 797 | } |
798 | 798 | |
799 | 799 | putenv('SHELL_VERBOSITY='.$shellVerbosity); |
800 | - $_ENV['SHELL_VERBOSITY'] = $shellVerbosity; |
|
801 | - $_SERVER['SHELL_VERBOSITY'] = $shellVerbosity; |
|
800 | + $_ENV[ 'SHELL_VERBOSITY' ] = $shellVerbosity; |
|
801 | + $_SERVER[ 'SHELL_VERBOSITY' ] = $shellVerbosity; |
|
802 | 802 | } |
803 | 803 | |
804 | 804 | /** |
@@ -273,8 +273,9 @@ discard block |
||
273 | 273 | $this->init(); |
274 | 274 | |
275 | 275 | if ($namespace == null) { |
276 | - if (!$this->commandLoader) |
|
277 | - return $this->commands; |
|
276 | + if (!$this->commandLoader) { |
|
277 | + return $this->commands; |
|
278 | + } |
|
278 | 279 | |
279 | 280 | $commands = array(); |
280 | 281 | foreach ($this->commandLoader->getNames() as $name) { |
@@ -364,14 +365,15 @@ discard block |
||
364 | 365 | } |
365 | 366 | |
366 | 367 | $exact = in_array($namespace, $namespaces, true); |
367 | - if (count($namespaces) > 1 && !$exact) |
|
368 | - throw new NamespaceNotFoundException( |
|
368 | + if (count($namespaces) > 1 && !$exact) { |
|
369 | + throw new NamespaceNotFoundException( |
|
369 | 370 | sprintf( |
370 | 371 | "The namespace \"%s\" is ambiguous.\nDid you mean one of these?\n%s", |
371 | 372 | $namespace, |
372 | 373 | $this->getAbbreviationSuggestions(array_values($namespaces))), |
373 | 374 | array_values($namespaces) |
374 | 375 | ); |
376 | + } |
|
375 | 377 | |
376 | 378 | return $exact ? $namespace : reset($namespaces); |
377 | 379 | } |
@@ -483,8 +485,9 @@ discard block |
||
483 | 485 | class_exists($class) |
484 | 486 | && $class != $excludeClass |
485 | 487 | && is_subclass_of($class, $excludeClass) |
486 | - ) |
|
487 | - $classes[] = new $class(); |
|
488 | + ) { |
|
489 | + $classes[] = new $class(); |
|
490 | + } |
|
488 | 491 | } |
489 | 492 | } |
490 | 493 |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | |
14 | 14 | class CommandLoader implements CommandLoaderInterface |
15 | 15 | { |
16 | - private $registeredCommands = []; |
|
16 | + private $registeredCommands = [ ]; |
|
17 | 17 | |
18 | 18 | private $defaultCommandPaths = [ |
19 | 19 | ROOT_PATH.'/app/custom/Commands' |
@@ -26,9 +26,9 @@ discard block |
||
26 | 26 | { |
27 | 27 | // load Commands from default paths |
28 | 28 | try { |
29 | - foreach($this->defaultCommandPaths as $directory) { |
|
29 | + foreach ($this->defaultCommandPaths as $directory) { |
|
30 | 30 | $files = glob($directory.'/*.php'); |
31 | - foreach($files as $file) { |
|
31 | + foreach ($files as $file) { |
|
32 | 32 | $this->registerByPath($file); |
33 | 33 | } |
34 | 34 | } |
@@ -46,8 +46,8 @@ discard block |
||
46 | 46 | */ |
47 | 47 | public function get($name) |
48 | 48 | { |
49 | - if($this->has($name)) { |
|
50 | - return $this->registeredCommands[$name]; |
|
49 | + if ($this->has($name)) { |
|
50 | + return $this->registeredCommands[ $name ]; |
|
51 | 51 | } else { |
52 | 52 | throw new CommandNotFoundException(sprintf('Command "%s" not found', $name)); |
53 | 53 | } |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | */ |
62 | 62 | public function has($name) |
63 | 63 | { |
64 | - return isset($this->registeredCommands[$name]); |
|
64 | + return isset($this->registeredCommands[ $name ]); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | /** |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | { |
83 | 83 | $command = $this->load($path); |
84 | 84 | |
85 | - if($command) { |
|
85 | + if ($command) { |
|
86 | 86 | $this->register($command); |
87 | 87 | } else { |
88 | 88 | throw new CommandNotFoundException("Can't find a fucking command."); |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | */ |
98 | 98 | public function add(Command $command) |
99 | 99 | { |
100 | - $this->registeredCommands[$command->getName()] = $command; |
|
100 | + $this->registeredCommands[ $command->getName() ] = $command; |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | /** |
@@ -108,8 +108,8 @@ discard block |
||
108 | 108 | private function register(Command $command) |
109 | 109 | { |
110 | 110 | // add to registered commands if not already registered. |
111 | - if(!$this->has($command->getName())) |
|
112 | - $this->registeredCommands[$command->getName()] = $command; |
|
111 | + if (!$this->has($command->getName())) |
|
112 | + $this->registeredCommands[ $command->getName() ] = $command; |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | /** |
@@ -120,13 +120,13 @@ discard block |
||
120 | 120 | */ |
121 | 121 | private function load($path) |
122 | 122 | { |
123 | - $file = explode(ROOT_PATH."/", explode('.php', $path)[0])[1]; |
|
123 | + $file = explode(ROOT_PATH."/", explode('.php', $path)[ 0 ])[ 1 ]; |
|
124 | 124 | $file = "\\".str_replace('/', '\\', $file); |
125 | 125 | |
126 | - if(class_exists($file)) { |
|
126 | + if (class_exists($file)) { |
|
127 | 127 | $tempClass = new $file; |
128 | 128 | |
129 | - if($tempClass instanceof Command) |
|
129 | + if ($tempClass instanceof Command) |
|
130 | 130 | return new $file; |
131 | 131 | } |
132 | 132 | return false; |
@@ -108,8 +108,9 @@ discard block |
||
108 | 108 | private function register(Command $command) |
109 | 109 | { |
110 | 110 | // add to registered commands if not already registered. |
111 | - if(!$this->has($command->getName())) |
|
112 | - $this->registeredCommands[$command->getName()] = $command; |
|
111 | + if(!$this->has($command->getName())) { |
|
112 | + $this->registeredCommands[$command->getName()] = $command; |
|
113 | + } |
|
113 | 114 | } |
114 | 115 | |
115 | 116 | /** |
@@ -126,8 +127,9 @@ discard block |
||
126 | 127 | if(class_exists($file)) { |
127 | 128 | $tempClass = new $file; |
128 | 129 | |
129 | - if($tempClass instanceof Command) |
|
130 | - return new $file; |
|
130 | + if($tempClass instanceof Command) { |
|
131 | + return new $file; |
|
132 | + } |
|
131 | 133 | } |
132 | 134 | return false; |
133 | 135 | } |