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

LogPathValidator   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 10
c 1
b 0
f 0
dl 0
loc 16
ccs 0
cts 6
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A validate() 0 14 3
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