| Conditions | 17 |
| Paths | 119 |
| Total Lines | 59 |
| Code Lines | 32 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 9 | ||
| 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 |
||
| 25 | public function HasCacheKeys(): bool |
||
| 26 | { |
||
| 27 | if (null === self::$_can_cache_content) { |
||
| 28 | self::$_can_cache_content_string = ''; |
||
| 29 | if ($this->owner->hasMethod('canCachePage')) { |
||
| 30 | self::$_can_cache_content_string = $this->owner->canCachePage() ? '' : 'can-no-cache-' . $this->owner->ID; |
||
| 31 | if (! $this->canCacheCheck()) { |
||
| 32 | return false; |
||
| 33 | } |
||
| 34 | } |
||
| 35 | |||
| 36 | //action |
||
| 37 | $action = $this->owner->request->param('Action'); |
||
| 38 | if ($action) { |
||
| 39 | self::$_can_cache_content_string .= $action; |
||
| 40 | if (! $this->canCacheCheck()) { |
||
| 41 | return false; |
||
| 42 | } |
||
| 43 | } |
||
| 44 | |||
| 45 | $id = $this->owner->request->param('ID'); |
||
| 46 | // id |
||
| 47 | if ($id) { |
||
| 48 | self::$_can_cache_content_string .= $id; |
||
| 49 | if (! $this->canCacheCheck()) { |
||
| 50 | return false; |
||
| 51 | } |
||
| 52 | } |
||
| 53 | |||
| 54 | //request vars |
||
| 55 | $requestVars = $this->owner->request->requestVars(); |
||
| 56 | if ($requestVars) { |
||
| 57 | foreach ($this->owner->request->requestVars() as $item) { |
||
| 58 | if (is_string($item)) { |
||
| 59 | self::$_can_cache_content_string .= $item; |
||
| 60 | } elseif (is_numeric($item)) { |
||
| 61 | self::$_can_cache_content_string .= $item; |
||
| 62 | } |
||
| 63 | |||
| 64 | if (! $this->canCacheCheck()) { |
||
| 65 | return false; |
||
| 66 | } |
||
| 67 | } |
||
| 68 | } |
||
| 69 | |||
| 70 | //member |
||
| 71 | $member = Security::getCurrentUser(); |
||
| 72 | if ($member && $member->exists()) { |
||
| 73 | self::$_can_cache_content_string .= $member->ID; |
||
| 74 | if (! $this->canCacheCheck()) { |
||
| 75 | return false; |
||
| 76 | } |
||
| 77 | } |
||
| 78 | |||
| 79 | // we are ok! |
||
| 80 | self::$_can_cache_content = true; |
||
| 81 | } |
||
| 82 | |||
| 83 | return self::$_can_cache_content; |
||
| 84 | } |
||
| 170 |