Conditions | 10 |
Paths | 18 |
Total Lines | 42 |
Code Lines | 23 |
Lines | 0 |
Ratio | 0 % |
Tests | 20 |
CRAP Score | 10.2217 |
Changes | 2 | ||
Bugs | 1 | 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 |
||
32 | 1 | protected function process() |
|
33 | { |
||
34 | 1 | $_sJobName = $this->oInput->getArgument('jobName'); |
|
35 | |||
36 | 1 | $_oChronosJobEntity = $this->checkInChronos($_sJobName); |
|
37 | 1 | $_oJobEntity = $_oChronosJobEntity == null ? $this->checkInMarathon($_sJobName) : $_oChronosJobEntity; |
|
38 | |||
39 | 1 | if (!$_oJobEntity) |
|
40 | { |
||
41 | $this->oOutput->writeln(sprintf('<fg=red>%s</>', 'Could not find the job.')); |
||
42 | return 1; |
||
43 | } |
||
44 | |||
45 | 1 | $this->oOutput->writeln(sprintf("\n<comment>info '%s'</comment>\n", $_oJobEntity->getKey())); |
|
46 | |||
47 | 1 | $_oTable = new Table($this->oOutput); |
|
48 | 1 | $_oTable->setHeaders(array('Property', 'Value')); |
|
49 | |||
50 | 1 | foreach ($_oJobEntity as $_sKey => $_mValue) |
|
51 | { |
||
52 | 1 | if (is_array($_mValue) || is_object($_mValue)) |
|
53 | { |
||
54 | 1 | $_sEmptyString = (is_object($_mValue)) ? '{ }' : '[ ]'; |
|
55 | |||
56 | 1 | $_mValue = (!empty($_mValue)) |
|
57 | ? json_encode($_mValue, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) |
||
58 | 1 | : $_sEmptyString; |
|
59 | } |
||
60 | 1 | elseif (is_bool($_mValue)) |
|
61 | { |
||
62 | 1 | $_mValue = (true === $_mValue) |
|
63 | 1 | ? 'true' |
|
64 | 1 | : 'false'; |
|
65 | } |
||
66 | |||
67 | 1 | $_oTable->addRow(array($_sKey, $_mValue)); |
|
68 | } |
||
69 | |||
70 | 1 | $_oTable->render(); |
|
71 | |||
72 | 1 | return 0; |
|
73 | } |
||
74 | |||
88 | } |