InMemoryRepository::retrieve()   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
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Krenor\Prometheus\Storage\Repositories;
4
5
use Tightenco\Collect\Support\Collection;
6
7
class InMemoryRepository extends SimpleRepository
8
{
9
    protected Collection $items;
10
11
    /**
12
     * InMemoryRepository constructor.
13
     */
14
    public function __construct()
15
    {
16
        $this->items = new Collection;
17
    }
18
19
    /**
20
     * {@inheritdoc}
21
     */
22 6
    protected function retrieve(string $key): mixed
23
    {
24 6
        return $this->items->get($key);
25
    }
26
27
    /**
28
     * {@inheritdoc}
29
     */
30 6
    protected function store(string $key, Collection $collection): bool
31
    {
32 6
        $this->items->put($key, $collection);
33
34 6
        return true;
35
    }
36
37
    /**
38
     * {@inheritdoc}
39
     */
40 6
    public function flush(): bool
41
    {
42 6
        $this->items = new Collection;
43
44 6
        return true;
45
    }
46
}
47