Conditions | 15 |
Paths | 10 |
Total Lines | 63 |
Code Lines | 37 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php declare(strict_types=1); |
||
58 | public function handle() |
||
59 | { |
||
60 | $name = $this->argument('name'); |
||
61 | |||
62 | $processor = new LaravelProcessor(); |
||
63 | |||
64 | // parse args |
||
65 | $processor->setRunModel($this->option('model') || $this->option('everything')); |
||
66 | $processor->setRunMigration($this->option('migration') || $this->option('everything')); |
||
67 | $processor->setRunFactory($this->option('factory') || $this->option('everything')); |
||
68 | $processor->setRunSeed($this->option('seed') || $this->option('everything')); |
||
69 | $processor->setRunPolicy($this->option('policy') || $this->option('everything')); |
||
70 | $processor->setRunEvent($this->option('event') || $this->option('everything')); |
||
71 | |||
72 | $files = [ |
||
73 | // todo __DIR__ . '/../../Graphql/definitions.graphql', |
||
74 | __DIR__ . '/../../../Types/Graphql/scalars.graphql' |
||
75 | ]; |
||
76 | |||
77 | if ($this->option('lighthouse')) { |
||
78 | // TODO: see issue #2 |
||
79 | // generate lighthouse directives |
||
80 | // $output = new BufferedOutput(); |
||
81 | // $this->call('lighthouse:ide-helper'); |
||
82 | // $output->fetch(); |
||
83 | |||
84 | $files[] = base_path('schema-directives.graphql'); |
||
|
|||
85 | } else { |
||
86 | $files[] = base_path(__DIR__ . '/../../Graphql/definitionsLighthouse.graphql'); |
||
87 | } |
||
88 | |||
89 | if ($name === '*' || $name === 'all') { |
||
90 | $path = base_path('graphql'); |
||
91 | $dir = \Safe\scandir($path); |
||
92 | |||
93 | // parse directives from lighthouse |
||
94 | $modelNames = array_diff($dir, array('.', '..')); |
||
95 | |||
96 | foreach ($modelNames as $n) { |
||
97 | if (mb_strpos($n, '.graphql') === false) { |
||
98 | continue; |
||
99 | } |
||
100 | $files[] = base_path('graphql/' . $n); |
||
101 | } |
||
102 | $processor->processFiles($files); |
||
103 | } elseif (!$name || is_array($name)) { |
||
104 | $this->error('Invalid name parameter'); |
||
105 | return; |
||
106 | } else { |
||
107 | try { |
||
108 | $data = \Safe\file_get_contents($this->getPathGraphql($name)); |
||
109 | $processor->processString($data); |
||
110 | } catch (\Safe\Exceptions\FilesystemException $e) { |
||
111 | $this->error("Cannot open model $name"); |
||
112 | } |
||
113 | } |
||
114 | |||
115 | $this->writeFiles( |
||
116 | $processor->getCollection(), |
||
117 | base_path(), |
||
118 | (bool)$this->option('overwrite') |
||
119 | ); |
||
120 | $this->info('Finished. You might want to run `composer dump-autoload`'); |
||
121 | } |
||
211 |