Passed
Pull Request — master (#46)
by Florian
04:42
created

DefaultCacheProvider::createMemoryCache()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2.032

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
b 0
f 0
dl 0
loc 10
ccs 4
cts 5
cp 0.8
rs 10
cc 2
nc 2
nop 0
crap 2.032
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Tebru\Gson\Internal;
6
7
use Psr\SimpleCache\CacheInterface;
8
use Symfony\Component\Cache\Adapter\Psr16Adapter;
9
10
final class DefaultCacheProvider
11
{
12
    public static function createFileCache(string $cacheDir): CacheInterface
13
    {
14
        // >= Symfony 4.3
15
        if (class_exists('Symfony\Component\Cache\Psr16Cache')) {
16
            return new \Symfony\Component\Cache\Psr16Cache(
17
                new \Symfony\Component\Cache\Adapter\ChainAdapter([
18
                    new Psr16Adapter(self::createMemoryCache()),
19
                    new \Symfony\Component\Cache\Adapter\PhpFilesAdapter('', 0, $cacheDir),
20
                ])
21
            );
22
        }
23
24
        return new \Symfony\Component\Cache\Simple\ChainCache([
0 ignored issues
show
Bug introduced by
The type Symfony\Component\Cache\Simple\ChainCache was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
25
            self::createMemoryCache(),
26
            new \Symfony\Component\Cache\Simple\PhpFilesCache('', 0, $cacheDir)
0 ignored issues
show
Bug introduced by
The type Symfony\Component\Cache\Simple\PhpFilesCache was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
27
        ]);
28
    }
29
30 3
    public static function createMemoryCache(): CacheInterface
31
    {
32
        // >= Symfony 4.3
33 3
        if (class_exists('Symfony\Component\Cache\Psr16Cache')) {
34 3
            return new \Symfony\Component\Cache\Psr16Cache(
35 3
                new \Symfony\Component\Cache\Adapter\ArrayAdapter(0, false)
36
            );
37
        }
38
39
        return new \Symfony\Component\Cache\Simple\ArrayCache(0, false);
0 ignored issues
show
Bug introduced by
The type Symfony\Component\Cache\Simple\ArrayCache was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
40
    }
41
42 3
    public static function createNullCache(): CacheInterface
43
    {
44
        // >= Symfony 4.3
45 3
        if (class_exists('Symfony\Component\Cache\Psr16Cache')) {
46 3
            return new \Symfony\Component\Cache\Psr16Cache(
47 3
                new \Symfony\Component\Cache\Adapter\NullAdapter()
48
            );
49
        }
50
51
        return new \Symfony\Component\Cache\Simple\NullCache();
0 ignored issues
show
Bug introduced by
The type Symfony\Component\Cache\Simple\NullCache was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
52
    }
53
}
54