| Conditions | 11 |
| Paths | 20 |
| Total Lines | 35 |
| Code Lines | 15 |
| 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 |
||
| 77 | public function hasIncludes(): bool |
||
| 78 | { |
||
| 79 | $seenExtends = false; |
||
| 80 | $seenBlock = false; |
||
| 81 | |||
| 82 | foreach ($this->nodeList as $token) { |
||
| 83 | if ($token instanceof ExtendsTag) { |
||
| 84 | $seenExtends = true; |
||
| 85 | } elseif ($token instanceof BlockTag) { |
||
| 86 | $seenBlock = true; |
||
| 87 | } |
||
| 88 | } |
||
| 89 | |||
| 90 | /* |
||
| 91 | * We try to keep the base templates in cache (that not extend anything). |
||
| 92 | * |
||
| 93 | * At the same time if we re-render all other blocks we see, we avoid most |
||
| 94 | * if not all related caching quirks. This may be suboptimal. |
||
| 95 | */ |
||
| 96 | if ($seenBlock && !$seenExtends) { |
||
| 97 | return true; |
||
| 98 | } |
||
| 99 | |||
| 100 | foreach ($this->nodeList as $token) { |
||
| 101 | // check any of the tokens for includes |
||
| 102 | if ($token instanceof IncludeTag && $token->hasIncludes()) { |
||
| 103 | return true; |
||
| 104 | } |
||
| 105 | |||
| 106 | if ($token instanceof ExtendsTag && $token->hasIncludes()) { |
||
| 107 | return true; |
||
| 108 | } |
||
| 109 | } |
||
| 110 | |||
| 111 | return false; |
||
| 112 | } |
||
| 132 |