Conditions | 2 |
Paths | 1 |
Total Lines | 52 |
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 declare (strict_types = 1); |
||
71 | public function handle() |
||
72 | { |
||
73 | $projectionRequest = collect(explode(',', $this->argument('projections'))); |
||
74 | |||
75 | $projectionsServiceProviders = $projectionRequest->each( |
||
76 | function ($projectionName) { |
||
77 | if (!isset($this->config->get('cqrses.projections_service_providers')[$projectionName])) { |
||
78 | $this->error("{$projectionName} Does not exist, check cqrses config"); |
||
79 | |||
80 | exit(); |
||
81 | } |
||
82 | } |
||
83 | )->map( |
||
84 | function ($projectionName) { |
||
85 | return $this->application->make( |
||
86 | $this->config->get('cqrses.projections_service_providers')[$projectionName] |
||
87 | ); |
||
88 | } |
||
89 | )->each( |
||
90 | function (ProjectionServiceProvider $projectionClass) { |
||
91 | $this->downMigration($projectionClass); |
||
92 | } |
||
93 | )->each( |
||
94 | function (ProjectionServiceProvider $projectionClass) { |
||
95 | $this->upMigration($projectionClass); |
||
96 | } |
||
97 | ); |
||
98 | |||
99 | /** @var Collection|Subscriber[] $projections */ |
||
100 | $projections = $projectionsServiceProviders->map( |
||
101 | function (ProjectionServiceProvider $projectServiceProvider) { |
||
102 | return collect($projectServiceProvider->getProjections())->map( |
||
103 | function ($projection) { |
||
104 | return $this->application->make($projection); |
||
105 | } |
||
106 | ); |
||
107 | } |
||
108 | )->collapse(); |
||
109 | |||
110 | $events = $projections->map( |
||
111 | function (Subscriber $subscriber) { |
||
112 | return array_keys($subscriber->getSubscribedEvents()); |
||
113 | } |
||
114 | )->collapse()->map( |
||
115 | function ($eventClassName) { |
||
116 | return str_replace('\\', '.', $eventClassName); |
||
117 | } |
||
118 | ); |
||
119 | |||
120 | $this->replayEvents($projections, $events); |
||
121 | |||
122 | } |
||
123 | |||
198 |