Counter::fetchCurrentIpList()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * This file is part of Esi\SimpleCounter.
7
 *
8
 * (c) Eric Sizemore <https://github.com/ericsizemore>
9
 *
10
 * This source file is subject to the MIT license. For the full copyright and
11
 * license information, please view the LICENSE file that was distributed with
12
 * this source code.
13
 */
14
15
namespace Esi\SimpleCounter;
16
17
use Esi\SimpleCounter\Interface\StorageInterface;
18
19
/**
20
 * Essentially a wrapper for a given Storage implementation.
21
 *
22
 * @see Tests\CounterTest
23
 */
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
49
    {
50 1
        return $this->storage->fetchCurrentCount();
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
67
    {
68 1
        return $this->storage->getOption($option);
69
    }
70
}
71