@@ -19,11 +19,11 @@ |
||
| 19 | 19 | |
| 20 | 20 | public function load($name) |
| 21 | 21 | { |
| 22 | - if(! isset($this->loaded[$name])){ |
|
| 22 | + if (!isset($this->loaded[$name])) { |
|
| 23 | 23 | $path = __DIR__ . "/../../templates/{$name}.wnt"; |
| 24 | 24 | try { |
| 25 | 25 | $this->loaded[$name] = $this->fs->get($path); |
| 26 | - } catch(\Exception $e) { |
|
| 26 | + } catch (\Exception $e) { |
|
| 27 | 27 | throw new TemplateException("Unable to read the file '{$path}'"); |
| 28 | 28 | } |
| 29 | 29 | } |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | |
| 34 | 34 | public function with($data = []) |
| 35 | 35 | { |
| 36 | - if($data) |
|
| 36 | + if ($data) |
|
| 37 | 37 | $this->dirty = true; |
| 38 | 38 | foreach ($data as $key => $value) { |
| 39 | 39 | $this->data[$key] = $value; |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | |
| 44 | 44 | public function get() |
| 45 | 45 | { |
| 46 | - if($this->dirty){ |
|
| 46 | + if ($this->dirty) { |
|
| 47 | 47 | $this->compile(); |
| 48 | 48 | $this->dirty = false; |
| 49 | 49 | } |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | public function compile() |
| 54 | 54 | { |
| 55 | 55 | $this->compiled = $this->text; |
| 56 | - foreach($this->data as $key => $value){ |
|
| 56 | + foreach ($this->data as $key => $value) { |
|
| 57 | 57 | $this->compiled = str_replace('{{' . $key . '}}', $value, $this->compiled); |
| 58 | 58 | } |
| 59 | 59 | return $this; |
@@ -26,7 +26,7 @@ |
||
| 26 | 26 | return $this->templates->load($name); |
| 27 | 27 | } |
| 28 | 28 | |
| 29 | - protected function getArgumentParser($name){ |
|
| 29 | + protected function getArgumentParser($name) { |
|
| 30 | 30 | $format = $this->argumentFormatLoader->load($name); |
| 31 | 31 | return new ArgumentParser($format); |
| 32 | 32 | } |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | protected function getFile() |
| 35 | 35 | { |
| 36 | 36 | $file = $this->option('file'); |
| 37 | - if(! $file){ |
|
| 37 | + if (!$file) { |
|
| 38 | 38 | $file = './database/factories/ModelFactory.php'; |
| 39 | 39 | } |
| 40 | 40 | return $file; |
@@ -46,12 +46,12 @@ discard block |
||
| 46 | 46 | |
| 47 | 47 | $fields = $this->option('fields'); |
| 48 | 48 | |
| 49 | - if($fields){ |
|
| 50 | - if(! $this->option('parsed')){ |
|
| 49 | + if ($fields) { |
|
| 50 | + if (!$this->option('parsed')) { |
|
| 51 | 51 | $fields = $this->getArgumentParser('factory-fields')->parse($fields); |
| 52 | 52 | } |
| 53 | 53 | $template = $this->getTemplate('factory/field'); |
| 54 | - foreach($fields as $field){ |
|
| 54 | + foreach ($fields as $field) { |
|
| 55 | 55 | $content[] = $template->with($field)->get(); |
| 56 | 56 | } |
| 57 | 57 | $content = implode(PHP_EOL, $content); |
@@ -41,14 +41,14 @@ |
||
| 41 | 41 | |
| 42 | 42 | protected function schema() |
| 43 | 43 | { |
| 44 | - return implode(' ', array_map(function($table){ |
|
| 44 | + return implode(' ', array_map(function($table) { |
|
| 45 | 45 | return $table . '_id:integer:unsigned:index'; |
| 46 | 46 | }, $this->tables)); |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | protected function keys() |
| 50 | 50 | { |
| 51 | - return implode(' ', array_map(function($table){ |
|
| 51 | + return implode(' ', array_map(function($table) { |
|
| 52 | 52 | return $table . '_id'; |
| 53 | 53 | }, $this->tables)); |
| 54 | 54 | } |
@@ -19,15 +19,15 @@ discard block |
||
| 19 | 19 | |
| 20 | 20 | public function load($name) |
| 21 | 21 | { |
| 22 | - if(! isset($this->loaded[$name])){ |
|
| 22 | + if (!isset($this->loaded[$name])) { |
|
| 23 | 23 | $path = __DIR__ . "/../../formats/{$name}.json"; |
| 24 | 24 | $json = ""; |
| 25 | 25 | try { |
| 26 | 26 | $json = json_decode($this->fs->get($path)); |
| 27 | - } catch(\Exception $e) { |
|
| 27 | + } catch (\Exception $e) { |
|
| 28 | 28 | throw new ArgumentFormatException("Unable to read the file '{$path}'"); |
| 29 | 29 | } |
| 30 | - if (json_last_error() !== JSON_ERROR_NONE){ |
|
| 30 | + if (json_last_error() !== JSON_ERROR_NONE) { |
|
| 31 | 31 | throw new ArgumentFormatException("Error while parsing the JSON file '{$path}'"); |
| 32 | 32 | } |
| 33 | 33 | $this->loaded[$name] = $this->buildFormat($json); |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | return $format; |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | - protected function fillObject($obj, $firstLevel=false) |
|
| 84 | + protected function fillObject($obj, $firstLevel = false) |
|
| 85 | 85 | { |
| 86 | 86 | $format = new ArgumentFormat; |
| 87 | 87 | |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | if (isset($obj->separator)) { |
| 108 | 108 | $format->separator = $obj->separator; |
| 109 | 109 | } elseif ($firstLevel) { |
| 110 | - $format->separator = ($format->type === 'object') ? ':':','; |
|
| 110 | + $format->separator = ($format->type === 'object') ? ':' : ','; |
|
| 111 | 111 | } |
| 112 | 112 | } |
| 113 | 113 | |
@@ -18,8 +18,8 @@ discard block |
||
| 18 | 18 | return $this->parseToken($args, $this->format); |
| 19 | 19 | } |
| 20 | 20 | |
| 21 | - protected function parseToken($token, ArgumentFormat $format){ |
|
| 22 | - switch($format->type) { |
|
| 21 | + protected function parseToken($token, ArgumentFormat $format) { |
|
| 22 | + switch ($format->type) { |
|
| 23 | 23 | case 'string': |
| 24 | 24 | return $token; |
| 25 | 25 | case 'number': |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | |
| 38 | 38 | protected function parseNumber($token) |
| 39 | 39 | { |
| 40 | - if(! is_numeric($token)) { |
|
| 40 | + if (!is_numeric($token)) { |
|
| 41 | 41 | throw new ArgumentParserException("Unable to parse '{$token}' as number"); |
| 42 | 42 | } |
| 43 | 43 | return $token + 0; |
@@ -45,9 +45,9 @@ discard block |
||
| 45 | 45 | |
| 46 | 46 | protected function parseBoolean($token, $name) |
| 47 | 47 | { |
| 48 | - if(in_array($token, ['yes', 'true', '1', $name])) { |
|
| 48 | + if (in_array($token, ['yes', 'true', '1', $name])) { |
|
| 49 | 49 | return true; |
| 50 | - } else if(in_array($token, ['no', 'false', '0', "!{$name}"])){ |
|
| 50 | + } else if (in_array($token, ['no', 'false', '0', "!{$name}"])) { |
|
| 51 | 51 | return false; |
| 52 | 52 | } else { |
| 53 | 53 | return null; |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | { |
| 59 | 59 | $result = []; |
| 60 | 60 | $tokens = explode($separator, $token); |
| 61 | - foreach($tokens as $value) { |
|
| 61 | + foreach ($tokens as $value) { |
|
| 62 | 62 | array_push($result, $this->parseToken($value, $format)); |
| 63 | 63 | } |
| 64 | 64 | return $result; |
@@ -72,8 +72,8 @@ discard block |
||
| 72 | 72 | |
| 73 | 73 | $requiredFieldsIndexes = []; |
| 74 | 74 | $optionalFieldsIndexes = []; |
| 75 | - foreach($fields as $index => $format) { |
|
| 76 | - if($format->default === null) { |
|
| 75 | + foreach ($fields as $index => $format) { |
|
| 76 | + if ($format->default === null) { |
|
| 77 | 77 | array_push($requiredFieldsIndexes, $index); |
| 78 | 78 | } else { |
| 79 | 79 | array_push($optionalFieldsIndexes, $index); |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | } |
| 82 | 82 | $requiredFieldsIndexesNumber = count($requiredFieldsIndexes); |
| 83 | 83 | |
| 84 | - if($tokensNumber < $requiredFieldsIndexesNumber) { |
|
| 84 | + if ($tokensNumber < $requiredFieldsIndexesNumber) { |
|
| 85 | 85 | $requiredFields = array_map(function($index) use ($fields) { |
| 86 | 86 | return $fields[$index]->name; |
| 87 | 87 | }, $requiredFieldsIndexes); |
@@ -98,13 +98,13 @@ discard block |
||
| 98 | 98 | sort($givenFieldsIndexes); |
| 99 | 99 | |
| 100 | 100 | // Fill the given fields |
| 101 | - for($i = 0; $i < $tokensNumber; $i ++) { |
|
| 101 | + for ($i = 0; $i < $tokensNumber; $i++) { |
|
| 102 | 102 | $fieldFormat = $fields[$givenFieldsIndexes[$i]]; |
| 103 | 103 | $result[$fieldFormat->name] = $this->parseToken($tokens[$i], $fieldFormat); |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | // Fill other fields with default values |
| 107 | - foreach($notPresentFieldsIndexes as $index) { |
|
| 107 | + foreach ($notPresentFieldsIndexes as $index) { |
|
| 108 | 108 | $fieldFormat = $fields[$index]; |
| 109 | 109 | $result[$fieldFormat->name] = $fieldFormat->default; |
| 110 | 110 | } |
@@ -1,8 +1,8 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -require_once __DIR__.'/../vendor/autoload.php'; |
|
| 3 | +require_once __DIR__ . '/../vendor/autoload.php'; |
|
| 4 | 4 | |
| 5 | -Dotenv::load(__DIR__.'/../'); |
|
| 5 | +Dotenv::load(__DIR__ . '/../'); |
|
| 6 | 6 | |
| 7 | 7 | /* |
| 8 | 8 | |-------------------------------------------------------------------------- |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | */ |
| 17 | 17 | |
| 18 | 18 | $app = new Laravel\Lumen\Application( |
| 19 | - realpath(__DIR__.'/../') |
|
| 19 | + realpath(__DIR__ . '/../') |
|
| 20 | 20 | ); |
| 21 | 21 | |
| 22 | 22 | $app->withFacades(); |
@@ -92,8 +92,8 @@ discard block |
||
| 92 | 92 | | |
| 93 | 93 | */ |
| 94 | 94 | |
| 95 | -$app->group(['namespace' => 'App\Http\Controllers'], function ($app) { |
|
| 96 | - require __DIR__.'/../app/Http/routes.php'; |
|
| 95 | +$app->group(['namespace' => 'App\Http\Controllers'], function($app) { |
|
| 96 | + require __DIR__ . '/../app/Http/routes.php'; |
|
| 97 | 97 | }); |
| 98 | 98 | |
| 99 | 99 | return $app; |
@@ -101,7 +101,7 @@ |
||
| 101 | 101 | " public static \$rules = [\n" . |
| 102 | 102 | " \"name\" => \"required\"," . PHP_EOL . |
| 103 | 103 | " \"age\" => \"integer|min:13\"," . PHP_EOL . |
| 104 | -" \"email\" => \"email|unique:users,email_address\",\n". |
|
| 104 | +" \"email\" => \"email|unique:users,email_address\",\n" . |
|
| 105 | 105 | " ];" |
| 106 | 106 | ); |
| 107 | 107 | |