Conditions | 5 |
Paths | 4 |
Total Lines | 59 |
Code Lines | 30 |
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 | /* @var StreamCollection $streams */ |
||
87 | $streams = $this->getStreams($slug); |
||
88 | |||
89 | $answers = $this->makeQuestion($streams); |
||
90 | |||
91 | if (array_search($this->getAllChoice(), $answers) === false) |
||
92 | { |
||
93 | $streams = $streams->filter( |
||
94 | function ($stream) use ($answers) |
||
95 | { |
||
96 | return array_search(ucfirst($stream->getSlug()), $answers) !== false; |
||
97 | } |
||
98 | ); |
||
99 | } |
||
100 | |||
101 | $streams->each( |
||
102 | function ($stream) use ($addon) |
||
103 | { |
||
104 | $slug = $stream->getSlug(); |
||
105 | |||
106 | $this->dispatch(new WriteEntitySeeder( |
||
107 | $addon, |
||
108 | $slug, |
||
109 | $stream->getNamespace() |
||
110 | )); |
||
111 | |||
112 | $singular = ucfirst(str_singular($slug)); |
||
113 | $path = "{$addon->getPath()}/src/{$singular}/{$singular}Seeder.php"; |
||
114 | |||
115 | $this->comment("Seeder for {$slug} created successfully."); |
||
116 | $this->line("Path: {$path}"); |
||
117 | $this->line(''); |
||
118 | } |
||
119 | ); |
||
120 | |||
121 | $this->dispatch(new WriteAddonSeeder($path, $type, $slug, $vendor, $streams)); |
||
122 | |||
123 | $this->composer->dumpAutoloads(); |
||
124 | |||
125 | $this->info('Seeders created successfully.'); |
||
126 | } |
||
127 | |||
221 |
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.