| Conditions | 10 |
| Paths | 7 |
| Total Lines | 26 |
| Code Lines | 14 |
| 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 |
||
| 47 | public function get(): ?string |
||
| 48 | { |
||
| 49 | /** @var mixed $id */ |
||
| 50 | $id = $this->session->get(self::SESSION_AUTH_ID); |
||
| 51 | |||
| 52 | if ( |
||
| 53 | $id !== null && |
||
| 54 | ($this->authTimeout !== null || $this->absoluteAuthTimeout !== null) |
||
| 55 | ) { |
||
| 56 | $expire = $this->getExpire(); |
||
| 57 | $expireAbsolute = $this->getExpireAbsoulte(); |
||
| 58 | |||
| 59 | if ( |
||
| 60 | ($expire !== null && $expire < time()) || |
||
| 61 | ($expireAbsolute !== null && $expireAbsolute < time()) |
||
| 62 | ) { |
||
| 63 | $this->clear(); |
||
| 64 | return null; |
||
| 65 | } |
||
| 66 | |||
| 67 | if ($this->authTimeout !== null) { |
||
| 68 | $this->session->set(self::SESSION_AUTH_EXPIRE, time() + $this->authTimeout); |
||
| 69 | } |
||
| 70 | } |
||
| 71 | |||
| 72 | return $id === null ? null : (string)$id; |
||
| 73 | } |
||
| 126 |