Passed
Pull Request — main (#48)
by Sílvio
03:09
created

FileCacheBatchProcessor::process()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 6
c 1
b 0
f 0
nc 2
nop 2
dl 0
loc 8
rs 10
1
<?php
2
3
namespace Silviooosilva\CacheerPhp\CacheStore\Support;
4
5
use Silviooosilva\CacheerPhp\CacheStore\FileCacheStore;
6
use Silviooosilva\CacheerPhp\Helpers\CacheFileHelper;
7
8
class FileCacheBatchProcessor
9
{
10
    public function __construct(private FileCacheStore $store)
11
    {
12
    }
13
14
    public function process(array $batchItems, string $namespace): void
15
    {
16
        foreach ($batchItems as $item) {
17
            CacheFileHelper::validateCacheItem($item);
18
            $cacheKey = $item['cacheKey'];
19
            $cacheData = $item['cacheData'];
20
            $mergedData = CacheFileHelper::mergeCacheData($cacheData);
21
            $this->store->putCache($cacheKey, $mergedData, $namespace);
22
        }
23
    }
24
}
25