Conditions | 11 |
Paths | 7 |
Total Lines | 28 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | 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 |
||
70 | public function supports(string $type, int $options = self::EXACT|self::COVARIANCE): bool |
||
71 | { |
||
72 | if (!$this->hasType()) { |
||
73 | // no type-hint so any type is supported |
||
74 | return true; |
||
75 | } |
||
76 | |||
77 | if ('null' === \mb_strtolower($type) && $this->parameter->allowsNull()) { |
||
78 | return true; |
||
79 | } |
||
80 | |||
81 | $type = self::TYPE_NORMALIZE_MAP[$type] ?? $type; |
||
82 | |||
83 | foreach ($this->types() as $supportedType) { |
||
84 | if ($options & self::EXACT && $supportedType === $type) { |
||
85 | return true; |
||
86 | } |
||
87 | |||
88 | if ($options & self::COVARIANCE && \is_a($type, $supportedType, true)) { |
||
89 | return true; |
||
90 | } |
||
91 | |||
92 | if ($options & self::CONTRAVARIANCE && \is_a($supportedType, $type, true)) { |
||
93 | return true; |
||
94 | } |
||
95 | } |
||
96 | |||
97 | return false; |
||
98 | } |
||
125 |