CacheCollection   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 27
rs 10
c 0
b 0
f 0
wmc 6

3 Methods

Rating   Name   Duplication   Size   Complexity  
A set() 0 4 2
A __construct() 0 3 1
A get() 0 11 3
1
<?php
2
3
namespace ICanBoogie\CLDR\Cache;
4
5
use ICanBoogie\CLDR\Cache;
6
7
/**
8
 * A collection of {@see Cache} instances.
9
 */
10
final class CacheCollection implements Cache
11
{
12
    /**
13
     * @param Cache[] $collection
14
     */
15
    public function __construct(
16
        private readonly array $collection
17
    ) {
18
    }
19
20
    public function get(string $path): ?array
21
    {
22
        foreach ($this->collection as $cache) {
23
            $data = $cache->get($path);
24
25
            if ($data !== null) {
26
                return $data;
27
            }
28
        }
29
30
        return null;
31
    }
32
33
    public function set(string $path, array $data): void
34
    {
35
        foreach ($this->collection as $cache) {
36
            $cache->set($path, $data);
37
        }
38
    }
39
}
40