Conditions | 10 |
Paths | 6 |
Total Lines | 24 |
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 |
||
45 | public function match($values): bool |
||
46 | { |
||
47 | if (! \is_iterable($values)) { |
||
48 | return false; |
||
49 | } |
||
50 | |||
51 | if (! parent::match($values)) { |
||
52 | return false; |
||
53 | } |
||
54 | |||
55 | if ($this->value || $this->key) { |
||
56 | foreach ($values as $key => $value) { |
||
57 | if ($this->key && ! $this->key->match($key)) { |
||
58 | return false; |
||
59 | } |
||
60 | |||
61 | if ($this->value && ! $this->value->match($value)) { |
||
62 | return false; |
||
63 | } |
||
64 | } |
||
65 | } |
||
66 | |||
67 | return true; |
||
68 | } |
||
69 | } |
||
70 |