Conditions | 1 |
Paths | 1 |
Total Lines | 61 |
Code Lines | 49 |
Lines | 0 |
Ratio | 0 % |
Tests | 49 |
CRAP Score | 1 |
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 |
||
21 | function bootstrap(OperatingSystem $os): Commands |
||
22 | { |
||
23 | 2 | $protocol = new Protocol\Json; |
|
24 | 2 | $watch = watch($os); |
|
25 | 2 | $ipc = ipc($os); |
|
26 | 2 | $monitor = new Name('lab-station-'.$os->process()->id()); |
|
27 | 2 | $git = new Git($os->control(), $os->clock()); |
|
28 | |||
29 | 2 | return new Commands( |
|
30 | 2 | new Command\Work( |
|
31 | 2 | new Monitor( |
|
32 | 2 | $protocol, |
|
33 | 2 | new Parallel( |
|
34 | 2 | new SubProcess($os->process()) |
|
35 | ), |
||
36 | 1 | $ipc, |
|
37 | 1 | $monitor, |
|
38 | 2 | new Trigger\All( |
|
39 | 2 | new Trigger\Graphs( |
|
40 | 2 | $os->filesystem(), |
|
41 | 2 | $os->control()->processes(), |
|
42 | 2 | $os->status()->tmp() |
|
43 | ), |
||
44 | 2 | new Trigger\Profiler( |
|
45 | 2 | $os->filesystem(), |
|
46 | 2 | $os->control()->processes() |
|
47 | ), |
||
48 | 2 | new Trigger\DockerCompose( |
|
49 | 2 | $os->filesystem(), |
|
50 | 2 | $os->control()->processes() |
|
51 | ), |
||
52 | 2 | new Trigger\Tests($os->control()->processes()), |
|
53 | 2 | new Trigger\Psalm( |
|
54 | 2 | $os->control()->processes(), |
|
55 | 2 | $os->filesystem() |
|
56 | ), |
||
57 | 2 | new Trigger\ComposerUpdate($os->control()->processes()), |
|
58 | 2 | new Trigger\GitRelease( |
|
59 | 2 | $git, |
|
60 | 2 | new SignedRelease, |
|
61 | 2 | new LatestVersion |
|
62 | ) |
||
63 | ), |
||
64 | 2 | new Agent\WatchSources( |
|
65 | 2 | $protocol, |
|
66 | 1 | $watch, |
|
67 | 1 | $ipc, |
|
68 | 1 | $monitor |
|
69 | ), |
||
70 | 2 | new Agent\WatchTests( |
|
71 | 2 | $protocol, |
|
72 | 1 | $watch, |
|
73 | 1 | $ipc, |
|
74 | 1 | $monitor |
|
75 | ), |
||
76 | 2 | new Agent\WatchCurrentGitBranch( |
|
77 | 2 | $git, |
|
78 | 1 | $protocol, |
|
79 | 1 | $watch, |
|
80 | 1 | $ipc, |
|
81 | 1 | $monitor |
|
82 | ) |
||
87 |