Passed
Pull Request — master (#323)
by Fabien
02:24
created

CachePath::validateValue()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 5
c 0
b 0
f 0
dl 0
loc 11
rs 10
cc 2
nc 2
nop 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Churn\Configuration\Validator;
6
7
use Churn\Configuration\EditableConfig;
8
use Webmozart\Assert\Assert;
9
10
/**
11
 * @internal
12
 */
13
final class CachePath extends BaseValidator
14
{
15
    /**
16
     * Class constructor.
17
     */
18
    public function __construct()
19
    {
20
        parent::__construct('cachePath');
21
    }
22
23
    /**
24
     * @param EditableConfig $config The configuration object.
25
     * @param mixed $value The value to validate.
26
     */
27
    protected function validateValue(EditableConfig $config, $value): void
28
    {
29
        if (null === $value) {
30
            $config->setCachePath(null);
31
32
            return;
33
        }
34
35
        Assert::string($value, 'Cache path should be a string');
36
37
        $config->setCachePath($value);
38
    }
39
}
40