Conditions | 10 |
Paths | 6 |
Total Lines | 29 |
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 |
||
66 | protected function invokePlugins(Translation $varTranslation, array $spec, callable $callback) |
||
67 | { |
||
68 | $value = $varTranslation->removeVars($varTranslation->translateString($spec['var'])); |
||
69 | $pass = false; |
||
70 | |||
71 | foreach ($spec as $key => $subValues) { |
||
72 | if (null === $subValues) { |
||
73 | continue; |
||
74 | } |
||
75 | |||
76 | foreach ((array) $subValues as $subValue) { |
||
77 | |||
78 | $isAnd = (0 === strpos($key, 'and')); |
||
79 | $isAnd and $key = lcfirst(substr($key, 3)); |
||
80 | |||
81 | if (empty($this->plugins[$key])) { |
||
82 | continue; |
||
83 | } |
||
84 | |||
85 | $expected = $varTranslation->removeVars($varTranslation->translateString($subValue)); |
||
86 | $this->fixTypes($value, $expected); |
||
87 | $bool = $this->plugins[$key]->__invoke($value, $expected); |
||
88 | $pass = $isAnd ? $pass && $bool : $pass || $bool; |
||
89 | } |
||
90 | } |
||
91 | |||
92 | $pass and $callback($spec); |
||
93 | return $this; |
||
94 | } |
||
95 | |||
124 |