Conditions | 6 |
Paths | 5 |
Total Lines | 66 |
Code Lines | 33 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 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 namespace Anomaly\Streams\Platform\Database\Seeder\Console; |
||
68 | public function fire() |
||
69 | { |
||
70 | /* @var Addon $addon */ |
||
71 | if (!$addon = $this->dispatch(new GetAddon($this->getAddonNamespace()))) |
||
72 | { |
||
73 | throw new \Exception('Addon could not be found.'); |
||
74 | } |
||
75 | |||
76 | $path = $addon->getPath(); |
||
77 | $type = $addon->getType(); |
||
78 | $slug = $addon->getSlug(); |
||
79 | $vendor = $addon->getVendor(); |
||
80 | |||
81 | if ($type != 'module' && $type != 'extension') |
||
82 | { |
||
83 | throw new \Exception('Only {module} and {extension} addon types are allowed!!!'); |
||
84 | } |
||
85 | |||
86 | if (!$this->confirm('Next action will OVERWRITE existing seeders which you would set! Do you agree?')) |
||
87 | { |
||
88 | $this->error('Exiting...'); |
||
89 | |||
90 | exit; |
||
91 | } |
||
92 | |||
93 | /* @var StreamCollection $streams */ |
||
94 | $streams = $this->getStreams($slug); |
||
95 | |||
96 | $answers = $this->makeQuestion($streams); |
||
97 | |||
98 | if (array_search($this->getAllChoice(), $answers) === false) |
||
99 | { |
||
100 | $streams = $streams->filter( |
||
101 | function ($stream) use ($answers) |
||
102 | { |
||
103 | return array_search(ucfirst($stream->getSlug()), $answers) !== false; |
||
104 | } |
||
105 | ); |
||
106 | } |
||
107 | |||
108 | $streams->each( |
||
109 | function ($stream) use ($addon) |
||
110 | { |
||
111 | $slug = $stream->getSlug(); |
||
112 | |||
113 | $this->dispatch(new WriteEntitySeeder( |
||
114 | $addon, |
||
115 | $slug, |
||
116 | $stream->getNamespace() |
||
117 | )); |
||
118 | |||
119 | $singular = ucfirst(str_singular($slug)); |
||
120 | $path = "{$addon->getPath()}/src/{$singular}/{$singular}Seeder.php"; |
||
121 | |||
122 | $this->comment("Seeder for {$slug} created successfully."); |
||
123 | $this->line("Path: {$path}"); |
||
124 | $this->line(''); |
||
125 | } |
||
126 | ); |
||
127 | |||
128 | $this->dispatch(new WriteAddonSeeder($path, $type, $slug, $vendor, $streams)); |
||
129 | |||
130 | $this->composer->dumpAutoloads(); |
||
131 | |||
132 | $this->info('Seeders created successfully.'); |
||
133 | } |
||
134 | |||
228 |
Adding a
@return
annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.Please refer to the PHP core documentation on constructors.