| Conditions | 6 |
| Paths | 8 |
| Total Lines | 52 |
| Code Lines | 17 |
| 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 |
||
| 70 | { |
||
| 71 | return isset($_SESSION[$variable]); |
||
| 72 | } |
||
| 73 | |||
| 74 | /** |
||
| 75 | * Clear |
||
| 76 | */ |
||
| 77 | static function clear() |
||
| 78 | { |
||
| 79 | $session = Container::getSession(); |
||
| 80 | $session->clear(); |
||
| 81 | } |
||
| 82 | |||
| 83 | /** |
||
| 84 | * Destroy |
||
| 85 | */ |
||
| 86 | static function destroy() |
||
| 87 | { |
||
| 88 | $session = Container::getSession(); |
||
| 89 | $session->invalidate(); |
||
| 90 | } |
||
| 91 | |||
| 92 | /* |
||
| 93 | * ArrayAccess |
||
| 94 | */ |
||
| 95 | public function offsetExists($offset) |
||
| 96 | { |
||
| 97 | return isset($_SESSION[$offset]); |
||
| 98 | } |
||
| 99 | |||
| 100 | /** |
||
| 101 | * It it exists returns the value stored at the specified offset. |
||
| 102 | * If offset does not exists returns null. Do not trigger a warning. |
||
| 103 | * |
||
| 104 | * @param string $offset |
||
| 105 | * @return any |
||
| 106 | */ |
||
| 107 | public function offsetGet($offset) |
||
| 108 | { |
||
| 109 | return self::read($offset); |
||
| 110 | } |
||
| 111 | |||
| 112 | public function offsetSet($offset, $value) |
||
| 113 | { |
||
| 114 | self::write($offset, $value); |
||
| 115 | } |
||
| 116 | |||
| 117 | public function offsetUnset($offset) |
||
| 118 | { |
||
| 119 | unset($_SESSION[$offset]); |
||
| 120 | } |
||
| 121 | |||
| 122 | /** |
||
| 163 |