InMemoryRepository   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Test Coverage

Coverage 72.72%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 38
ccs 8
cts 11
cp 0.7272
rs 10
c 1
b 0
f 0
eloc 8
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A flush() 0 5 1
A retrieve() 0 3 1
A store() 0 5 1
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