Completed
Push — master ( 7353e9...0c9da4 )
by BENOIT
01:14
created

ArrayAdapter::deleteCounter()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace BenTools\GuzzleHttp\Middleware\Storage\Adapter;
4
5
use BenTools\GuzzleHttp\Middleware\Storage\Counter;
6
use BenTools\GuzzleHttp\Middleware\Storage\ThrottleStorageInterface;
7
8
class ArrayAdapter implements ThrottleStorageInterface
9
{
10
11
    private $storage = [];
12
13
    /**
14
     * @inheritDoc
15
     */
16
    public function hasCounter(string $storageKey): bool
17
    {
18
        return isset($this->storage[$storageKey]);
19
    }
20
21
    /**
22
     * @inheritDoc
23
     */
24
    public function getCounter(string $storageKey)
25
    {
26
        return $this->storage[$storageKey] ?? null;
27
    }
28
29
    /**
30
     * @inheritDoc
31
     */
32
    public function saveCounter(string $storageKey, Counter $counter, float $ttl = null)
33
    {
34
        $this->storage[$storageKey] = $counter;
35
    }
36
37
    /**
38
     * @inheritDoc
39
     */
40
    public function deleteCounter(string $storageKey)
41
    {
42
        unset($this->storage[$storageKey]);
43
    }
44
}
45