CacheFactory   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 10
c 1
b 0
f 1
dl 0
loc 23
rs 10
ccs 0
cts 11
cp 0
wmc 5

2 Methods

Rating   Name   Duplication   Size   Complexity  
A createSimpleCache() 0 14 4
A getCacheType() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of forecast.it.fill project.
7
 * (c) Patrick Jaja <[email protected]>
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
namespace ForecastAutomation\Cache;
13
14
use ForecastAutomation\Kernel\AbstractFactory;
15
use Shieldon\SimpleCache\Cache;
16
17
class CacheFactory extends AbstractFactory
18
{
19
    public function createSimpleCache(): Cache
20
    {
21
        if (! file_exists('/tmp/simple-cache')
22
            && ! mkdir('/tmp/simple-cache', 0777, true)
23
            && ! is_dir(
24
                '/tmp/simple-cache'
25
            )) {
26
            throw new \RuntimeException(sprintf('Directory "%s" was not created', '/tmp/simple-cache'));
27
        }
28
29
        return new Cache(
30
            $this->getCacheType(),
31
            [
32
                'storage' => '/tmp/simple-cache',
33
            ]
34
        );
35
    }
36
37
    public function getCacheType(): string
38
    {
39
        return 'file';
40
    }
41
}
42