| Conditions | 14 |
| Paths | 193 |
| Total Lines | 55 |
| Code Lines | 30 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 15 | ||
| 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 |
||
| 43 | */ |
||
| 44 | public function HasCacheKeys(): bool |
||
| 45 | { |
||
| 46 | $owner = $this->getOwner(); |
||
| 47 | if (null === self::$_can_cache_content) { |
||
| 48 | $canCache = true; |
||
| 49 | self::$_can_cache_content_string = ''; |
||
| 50 | if ($owner->hasMethod('canCachePage')) { |
||
| 51 | // if it can cache the page, then it the cache string will remain empty. |
||
| 52 | $canCache = $owner->canCachePage(); |
||
| 53 | self::$_can_cache_content_string .= $canCache ? '' : $this->getRandomKey(); |
||
| 54 | } |
||
| 55 | |||
| 56 | //action |
||
| 57 | $action = $owner->request->param('Action'); |
||
| 58 | if ($action) { |
||
| 59 | self::$_can_cache_content_string .= 'UA' . $action; |
||
| 60 | } |
||
| 61 | |||
| 62 | // id |
||
| 63 | $id = $owner->request->param('ID'); |
||
| 64 | if ($id) { |
||
| 65 | self::$_can_cache_content_string .= 'UI' . $id; |
||
| 66 | } |
||
| 67 | |||
| 68 | // otherid |
||
| 69 | $otherId = $owner->request->param('OtherID'); |
||
| 70 | if ($otherId) { |
||
| 71 | self::$_can_cache_content_string .= 'UI' . $otherId; |
||
| 72 | } |
||
| 73 | |||
| 74 | //request vars |
||
| 75 | $requestVars = $owner->request->requestVars(); |
||
| 76 | if ($requestVars) { |
||
| 77 | foreach ($owner->request->requestVars() as $key => $item) { |
||
| 78 | <<<<<<< HEAD |
||
|
|
|||
| 79 | $canCache = false; |
||
| 80 | ======= |
||
| 81 | >>>>>>> 5e6d7b8a22bfca77ec46593a5063fa14ef3c3e64 |
||
| 82 | if (! $item) { |
||
| 83 | $item = ''; |
||
| 84 | } |
||
| 85 | self::$_can_cache_content_string .= serialize($key . '_' . serialize($item)); |
||
| 86 | } |
||
| 87 | } |
||
| 88 | |||
| 89 | if (Versioned::get_reading_mode() !== 'Stage.Live') { |
||
| 90 | self::$_can_cache_content_string .= 'V' . Versioned::get_reading_mode(); |
||
| 91 | $canCache = false; |
||
| 92 | } |
||
| 93 | |||
| 94 | //member |
||
| 95 | $member = Security::getCurrentUser(); |
||
| 96 | if ($member && $member->exists()) { |
||
| 97 | if (Config::inst()->get(self::class, 'unique_cache_for_each_member')) { |
||
| 98 | self::$_can_cache_content_string .= 'UM' . $member->ID; |
||
| 217 |