Conditions | 8 |
Paths | 8 |
Total Lines | 59 |
Code Lines | 47 |
Lines | 0 |
Ratio | 0 % |
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 |
||
25 | function getEvidenceActions($evidence, FlexiBeeRO $syncer) |
||
26 | { |
||
27 | $columns = $syncer->getColumnsInfo($evidence); |
||
28 | if (array_key_exists('zamekK', $columns)) { |
||
29 | $syncer->addStatusMessage('Adding LOCK actions to evidence '.$evidence, |
||
30 | 'debug'); |
||
31 | $actions = [ |
||
32 | 'lock' => [ |
||
33 | 'actionId' => 'lock', |
||
34 | 'actionName' => 'Zamknout', |
||
35 | 'needInstance' => 'true', |
||
36 | 'actionMakesSense' => 'ONLY_WITH_INSTANCE_AND_NOT_IN_CREATE', |
||
37 | 'isRealAction' => 'true', |
||
38 | 'isService' => 'YES', |
||
39 | ], |
||
40 | 'lock-for-ucetni' => [ |
||
41 | 'actionId' => 'lock-for-ucetni', |
||
42 | 'actionName' => 'Zamknout pro učetní', |
||
43 | 'needInstance' => 'true', |
||
44 | 'actionMakesSense' => 'ONLY_WITH_INSTANCE_AND_NOT_IN_CREATE', |
||
45 | 'isRealAction' => 'true', |
||
46 | 'isService' => 'YES', |
||
47 | ], |
||
48 | 'unlock' => [ |
||
49 | 'actionId' => 'unlock', |
||
50 | 'actionName' => 'Odemknout', |
||
51 | 'needInstance' => 'true', |
||
52 | 'actionMakesSense' => 'ONLY_WITH_INSTANCE_AND_NOT_IN_CREATE', |
||
53 | 'isRealAction' => 'true', |
||
54 | 'isService' => 'YES', |
||
55 | ] |
||
56 | ]; |
||
57 | } else { |
||
58 | $actions = []; |
||
59 | } |
||
60 | $flexinfo = $syncer->performRequest($evidence.'/actions.json'); |
||
61 | if (count($flexinfo) && array_key_exists('actions', $flexinfo)) { |
||
62 | if (isset($flexinfo['actions']['action'])) { |
||
63 | if (\Ease\Functions::isAssoc($flexinfo['actions']['action'])) { |
||
64 | $key = $flexinfo['actions']['action']['actionId']; |
||
65 | $actions[$key] = $flexinfo['actions']['action']; |
||
66 | } else { |
||
67 | foreach ($flexinfo['actions']['action'] as $evidenceActions) { |
||
68 | if (array_key_exists('actionId', $evidenceActions)) { |
||
69 | $key = $evidenceActions['actionId']; |
||
70 | $actions[$key] = $evidenceActions; |
||
71 | } else { |
||
72 | $syncer->addStatusMessage(sprintf('actionId not set for %s', |
||
73 | $evidence.' / '.$evidenceActions['actionName']), |
||
74 | 'warning'); |
||
75 | } |
||
76 | } |
||
77 | } |
||
78 | } else { |
||
79 | $syncer->addStatusMessage(sprintf('Missing actions for %s', |
||
80 | $evidence), 'warning'); |
||
81 | } |
||
82 | } |
||
83 | return $actions; |
||
84 | } |
||
155 |