Conditions | 10 |
Paths | 72 |
Total Lines | 39 |
Lines | 0 |
Ratio | 0 % |
Tests | 17 |
CRAP Score | 10.6913 |
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 |
||
17 | 1 | public function run(Filesystem $fs) |
|
18 | { |
||
19 | 1 | $result = []; |
|
20 | 1 | $cache = $fs->getPath('.cache'); |
|
21 | 1 | if (is_dir($cache)) { |
|
22 | 1 | foreach ($fs->listFiles('.cache') as $file) { |
|
23 | 1 | unlink($fs->getPath('.cache/'.$file)); |
|
24 | } |
||
25 | } |
||
26 | |||
27 | try { |
||
28 | 1 | foreach ([Framework::class, Filesystem::class] as $source) { |
|
29 | 1 | $procedures = $this->get($source)->listClasses('Procedure'); |
|
30 | 1 | if (count($procedures)) { |
|
31 | 1 | foreach ($procedures as $procedure) { |
|
32 | 1 | $this->get(Mapper::class)->getPlugin(Procedure::class)->register($procedure); |
|
33 | } |
||
34 | } |
||
35 | } |
||
36 | } catch (Exception $e) { |
||
37 | // ignore issues on procedure registration |
||
38 | $result['procedures'] = $e->getMessage(); |
||
39 | } |
||
40 | |||
41 | 1 | foreach ($this->jobs as $job) { |
|
42 | try { |
||
43 | 1 | $result[$job] = $this->dispatch($job); |
|
44 | } catch (Exception $e) { |
||
45 | $result[$job] = $e->getMessage(); |
||
46 | } |
||
47 | } |
||
48 | |||
49 | 1 | if ($this->app->has(Mapper::class)) { |
|
50 | 1 | $this->get(Mapper::class)->getPlugin(Procedure::class) |
|
51 | 1 | ->register(Select::class); |
|
52 | } |
||
53 | |||
54 | 1 | return $result; |
|
55 | } |
||
56 | } |
||
57 |