| Total Complexity | 5 |
| Total Lines | 45 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 24 | readonly class Counter |
||
| 25 | { |
||
| 26 | /** |
||
| 27 | * Current Simple Counter package version. |
||
| 28 | */ |
||
| 29 | public const VERSION = '6.0.0'; |
||
| 30 | |||
| 31 | /** |
||
| 32 | * $storage should be one of the available Storage implementations that has already |
||
| 33 | * been instantiated with their relevant Configuration. |
||
| 34 | */ |
||
| 35 | 4 | public function __construct(private StorageInterface $storage) {} |
|
| 36 | |||
| 37 | /** |
||
| 38 | * Updates count and formats for display, for the given Storage implementation. |
||
| 39 | */ |
||
| 40 | 3 | public function display(): string |
|
| 41 | { |
||
| 42 | 3 | return $this->storage->display(); |
|
| 43 | } |
||
| 44 | |||
| 45 | /** |
||
| 46 | * Useful for retrieving the current count without triggering an update. |
||
| 47 | */ |
||
| 48 | 1 | public function fetchCurrentCount(): int |
|
| 51 | } |
||
| 52 | |||
| 53 | /** |
||
| 54 | * Returns ip data, if any exists. |
||
| 55 | * |
||
| 56 | * @return list<string> |
||
| 57 | */ |
||
| 58 | 1 | public function fetchCurrentIpList(): array |
|
| 59 | { |
||
| 60 | 1 | return $this->storage->fetchCurrentIpList(); |
|
| 61 | } |
||
| 62 | |||
| 63 | /** |
||
| 64 | * Returns the given option, if it exists. |
||
| 65 | */ |
||
| 66 | 1 | public function getOption(string $option): null|bool|string |
|
| 69 | } |
||
| 70 | } |
||
| 71 |