| Conditions | 2 |
| Paths | 2 |
| Total Lines | 13 |
| Code Lines | 3 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 4 |
| CRAP Score | 2 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 13 | 4 | final public function count(): int |
|
| 14 | { |
||
| 15 | // Since a new adapter instance is created every time visits are fetched, it is reasonably safe to internally |
||
| 16 | // cache the count value. |
||
| 17 | // The reason it is cached is because the Paginator is actually calling the method twice. |
||
| 18 | // An inconsistent value could be returned if between the first call and the second one, a new visit is created. |
||
| 19 | // However, it's almost instant, and then the adapter instance is discarded immediately after. |
||
| 20 | |||
| 21 | 4 | if ($this->count !== null) { |
|
| 22 | 4 | return $this->count; |
|
| 23 | } |
||
| 24 | |||
| 25 | 4 | return $this->count = $this->doCount(); |
|
| 26 | } |
||
| 30 |