FileExistsConstraint::validate()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 4
c 0
b 0
f 0
nc 2
nop 1
dl 0
loc 6
rs 10
1
<?php
2
3
namespace Startwind\Forrest\Command\Parameters\Validation\Constraint\File;
4
5
use Startwind\Forrest\Command\Parameters\Validation\Constraint\Constraint;
6
use Startwind\Forrest\Command\Parameters\Validation\SuccessfulValidationResult;
7
use Startwind\Forrest\Command\Parameters\Validation\ValidationResult;
8
9
class FileExistsConstraint implements Constraint
10
{
11
    public static function validate(string $value): ValidationResult
12
    {
13
        if (!file_exists($value)) {
14
            return new ValidationResult(false, "Cannot find file '" . $value . "'.");
15
        } else {
16
            return new SuccessfulValidationResult();
17
        }
18
    }
19
}
20