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; |
||
65 | public function fire() |
||
66 | { |
||
67 | /* @var Addon $addon */ |
||
68 | if (!$addon = $this->dispatch(new GetAddon($this->getAddonNamespace()))) |
||
69 | { |
||
70 | throw new \Exception('Addon could not be found.'); |
||
71 | } |
||
72 | |||
73 | $path = $addon->getPath(); |
||
74 | $type = $addon->getType(); |
||
75 | $slug = $addon->getSlug(); |
||
76 | $vendor = $addon->getVendor(); |
||
77 | |||
78 | if ($type != 'module' && $type != 'extension') |
||
79 | { |
||
80 | throw new \Exception('Only {module} and {extension} addon types are allowed!!!'); |
||
81 | } |
||
82 | |||
83 | /* @var StreamCollection $streams */ |
||
84 | $streams = $this->getStreams($slug); |
||
85 | |||
86 | $answers = $this->makeQuestion($streams); |
||
87 | |||
88 | if (array_search($this->getAllChoice(), $answers) === false) |
||
89 | { |
||
90 | $streams = $streams->filter( |
||
91 | function ($stream) use ($answers) |
||
92 | { |
||
93 | return array_search(ucfirst($stream->getSlug()), $answers) !== false; |
||
94 | } |
||
95 | ); |
||
96 | } |
||
97 | |||
98 | $streams->each( |
||
99 | function ($stream) use ($addon) |
||
100 | { |
||
101 | $slug = $stream->getSlug(); |
||
102 | |||
103 | $this->dispatch(new WriteEntitySeeder( |
||
104 | $addon, |
||
105 | $slug, |
||
106 | $stream->getNamespace() |
||
107 | )); |
||
108 | |||
109 | $slug = ucfirst($slug); |
||
110 | $path = "{$addon->getPath()}/{$slug}/{$slug}Seeder.php"; |
||
111 | |||
112 | $this->comment("Seeder for {$slug} created successfully."); |
||
113 | $this->line("Path: {$path}"); |
||
114 | $this->line(''); |
||
115 | } |
||
116 | ); |
||
117 | |||
118 | $this->dispatch(new WriteAddonSeeder($path, $type, $slug, $vendor, $streams)); |
||
119 | |||
120 | $this->composer->dumpAutoloads(); |
||
121 | |||
122 | $this->info('Seeders created successfully.'); |
||
123 | } |
||
124 | |||
218 |
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.