Passed
Push — main ( 764702...024f60 )
by Daniel
04:19
created

LogPathValidator::validate()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 14
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 14
ccs 0
cts 6
cp 0
rs 9.9666
cc 3
nc 3
nop 0
crap 12
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Uxmp\Core\Component\Setup\Validator;
6
7
use Uxmp\Core\Component\Setup\Validator\Exception\EnvironmentValidationException;
8
9
final class LogPathValidator implements ValidatorInterface
10
{
11
    public function validate(): void
12
    {
13
        $logPath = $_ENV['LOG_PATH'] ?? '';
14
        if ($logPath === '') {
15
            throw new EnvironmentValidationException(
16
                'LOG_PATH is not set in config'
17
            );
18
        }
19
20
        if (!is_writeable($logPath)) {
21
            throw new EnvironmentValidationException(
22
                sprintf(
23
                    'LOG_PATH `%s` is not a valid writeable directory',
24
                    $logPath
25
                )
26
            );
27
        }
28
    }
29
}
30