| @@ -38,8 +38,9 @@ discard block | ||
| 38 | 38 | |
| 39 | 39 |      public static function create(callable $action = null) { | 
| 40 | 40 | $command = new Command; | 
| 41 | - if (null !== $action) | |
| 42 | - $command->action($action); | |
| 41 | +        if (null !== $action) { | |
| 42 | + $command->action($action); | |
| 43 | + } | |
| 43 | 44 | return $command; | 
| 44 | 45 | } | 
| 45 | 46 | |
| @@ -126,8 +127,9 @@ discard block | ||
| 126 | 127 | */ | 
| 127 | 128 | public function syntax(string $syntax = null) | 
| 128 | 129 |      { | 
| 129 | - if (null === $syntax) | |
| 130 | - return $this->syntax; | |
| 130 | +        if (null === $syntax) { | |
| 131 | + return $this->syntax; | |
| 132 | + } | |
| 131 | 133 | |
| 132 | 134 |          $this->syntax = S::syntax()->parse("{{$syntax}| }"); | 
| 133 | 135 | return $this; | 
| @@ -146,8 +148,9 @@ discard block | ||
| 146 | 148 | } | 
| 147 | 149 | |
| 148 | 150 | $this->options = []; | 
| 149 | - foreach($options as $option) | |
| 150 | - $this->options[$option] = false; | |
| 151 | +        foreach($options as $option) { | |
| 152 | + $this->options[$option] = false; | |
| 153 | + } | |
| 151 | 154 | |
| 152 | 155 | return $this; | 
| 153 | 156 | } | 
| @@ -160,8 +163,9 @@ discard block | ||
| 160 | 163 | */ | 
| 161 | 164 | public function option(string $name) | 
| 162 | 165 |      { | 
| 163 | - if (!array_key_exists($name, $this->options)) | |
| 164 | -            throw new \InvalidArgumentException("Unknown option '{$name}'"); | |
| 166 | +        if (!array_key_exists($name, $this->options)) { | |
| 167 | +                    throw new \InvalidArgumentException("Unknown option '{$name}'"); | |
| 168 | + } | |
| 165 | 169 | return $this->options[$name]; | 
| 166 | 170 | } | 
| 167 | 171 | |
| @@ -209,8 +213,9 @@ discard block | ||
| 209 | 213 |          if (null === $value) { | 
| 210 | 214 | return $this->fs; | 
| 211 | 215 | } | 
| 212 | - if (is_string($value)) | |
| 213 | - $value = new Filesystem($value); | |
| 216 | +        if (is_string($value)) { | |
| 217 | + $value = new Filesystem($value); | |
| 218 | + } | |
| 214 | 219 | $this->fs = $value; | 
| 215 | 220 |          foreach ($this->commands as $name => $command) { | 
| 216 | 221 | $command->fs = $value; | 
| @@ -247,8 +252,9 @@ discard block | ||
| 247 | 252 | |
| 248 | 253 | public function template(string $name) | 
| 249 | 254 |      { | 
| 250 | - if (null === $this->templatesLoader) | |
| 251 | -            throw new \Exception("Please initialize the templates loader before trying to load templates!"); | |
| 255 | +        if (null === $this->templatesLoader) { | |
| 256 | +                    throw new \Exception("Please initialize the templates loader before trying to load templates!"); | |
| 257 | + } | |
| 252 | 258 | return $this->templatesLoader->load($name); | 
| 253 | 259 | } | 
| 254 | 260 | |
| @@ -303,8 +309,9 @@ discard block | ||
| 303 | 309 | public function command(string $name, Command $command = null) | 
| 304 | 310 |      { | 
| 305 | 311 |          if (null === $command) { | 
| 306 | - if (!array_key_exists($name, $this->commands)) | |
| 307 | -                throw new \InvalidArgumentException("subcommand '{$name}' not found!"); | |
| 312 | +            if (!array_key_exists($name, $this->commands)) { | |
| 313 | +                            throw new \InvalidArgumentException("subcommand '{$name}' not found!"); | |
| 314 | + } | |
| 308 | 315 | return $this->commands[$name]; | 
| 309 | 316 | } | 
| 310 | 317 | $this->commands[$name] = $command; | 
| @@ -325,9 +332,10 @@ discard block | ||
| 325 | 332 | |
| 326 | 333 | public function describe(string $name, string $description = null) | 
| 327 | 334 |      { | 
| 328 | - if (null === $description) | |
| 329 | - return array_key_exists($name, $this->descriptions) | |
| 335 | +        if (null === $description) { | |
| 336 | + return array_key_exists($name, $this->descriptions) | |
| 330 | 337 | ? $this->descriptions[$name] : ''; | 
| 338 | + } | |
| 331 | 339 |          if (substr($name, 0, 2) == '--' && array_key_exists($name, $this->options())) { | 
| 332 | 340 | $this->descriptions[$name] = $description; | 
| 333 | 341 | return $this; | 
| @@ -363,8 +371,9 @@ discard block | ||
| 363 | 371 |              } else { | 
| 364 | 372 | $this->args = (object) $args; | 
| 365 | 373 |                  foreach ($options as $name) { | 
| 366 | - if (!array_key_exists($name, $this->options)) | |
| 367 | -                        throw new \Exception("Unknown option '{$name}'"); | |
| 374 | +                    if (!array_key_exists($name, $this->options)) { | |
| 375 | +                                            throw new \Exception("Unknown option '{$name}'"); | |
| 376 | + } | |
| 368 | 377 | $this->options[$name] = true; | 
| 369 | 378 | } | 
| 370 | 379 | } | 
| @@ -399,10 +408,11 @@ discard block | ||
| 399 | 408 | |
| 400 | 409 | $arguments = []; | 
| 401 | 410 |          foreach ($args as &$arg) { | 
| 402 | - if (array_key_exists($arg, $this->options)) | |
| 403 | - $this->options[$arg] = true; | |
| 404 | - else | |
| 405 | - $arguments[] = $arg; | |
| 411 | +            if (array_key_exists($arg, $this->options)) { | |
| 412 | + $this->options[$arg] = true; | |
| 413 | +            } else { | |
| 414 | + $arguments[] = $arg; | |
| 415 | + } | |
| 406 | 416 | } | 
| 407 | 417 | $arguments = T::join($arguments, ' '); | 
| 408 | 418 | $this->args = $this->syntax->parse($arguments); | 
| @@ -22,13 +22,15 @@ | ||
| 22 | 22 | */ | 
| 23 | 23 | public function get(string $path = null) | 
| 24 | 24 |      { | 
| 25 | - if (null === $path) | |
| 26 | - return $this->data; | |
| 25 | +        if (null === $path) { | |
| 26 | + return $this->data; | |
| 27 | + } | |
| 27 | 28 |          $keys = explode('.', $path); | 
| 28 | 29 | $value = $this->data; | 
| 29 | 30 |          foreach ($keys as $key) { | 
| 30 | - if (!is_array($value) || !array_key_exists($key, $value)) | |
| 31 | -                throw new \Exception("Unable to find a configuration value with path '{$path}'"); | |
| 31 | +            if (!is_array($value) || !array_key_exists($key, $value)) { | |
| 32 | +                            throw new \Exception("Unable to find a configuration value with path '{$path}'"); | |
| 33 | + } | |
| 32 | 34 | $value = $value[$key]; | 
| 33 | 35 | } | 
| 34 | 36 | return $value; | 
| @@ -24,8 +24,9 @@ discard block | ||
| 24 | 24 | |
| 25 | 25 | public function load(array $paths) : ConfigInterface | 
| 26 | 26 |      { | 
| 27 | - if (empty($paths)) | |
| 28 | - return new Config([]); | |
| 27 | +        if (empty($paths)) { | |
| 28 | + return new Config([]); | |
| 29 | + } | |
| 29 | 30 | $data = []; | 
| 30 | 31 |          foreach ($paths as $path) { | 
| 31 | 32 | $data[] = $this->decode($path); | 
| @@ -35,12 +36,14 @@ discard block | ||
| 35 | 36 | } | 
| 36 | 37 | |
| 37 | 38 |      protected function decode(string $path) : array { | 
| 38 | - if (! $this->fs->isFile($path)) | |
| 39 | - return []; | |
| 39 | +        if (! $this->fs->isFile($path)) { | |
| 40 | + return []; | |
| 41 | + } | |
| 40 | 42 | $file = $this->fs->file($path); | 
| 41 | 43 | $ext = $file->extension(); | 
| 42 | - if (! array_key_exists($ext, static::$decoders)) | |
| 43 | -            throw new \Exception("Unknown configuration file extension '{$ext}'"); | |
| 44 | +        if (! array_key_exists($ext, static::$decoders)) { | |
| 45 | +                    throw new \Exception("Unknown configuration file extension '{$ext}'"); | |
| 46 | + } | |
| 44 | 47 | $decoderClass = static::$decoders[$ext]; | 
| 45 | 48 | $decoder = new $decoderClass; | 
| 46 | 49 | return $decoder->decode($file->content()); |