FileNotExistsConstraint   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 8
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 5
c 0
b 0
f 0
dl 0
loc 8
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A validate() 0 6 2
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 FileNotExistsConstraint implements Constraint
10
{
11
    public static function validate(string $value): ValidationResult
12
    {
13
        if (file_exists($value)) {
14
            return new ValidationResult(false, "The file '" . $value . "' already exists.");
15
        } else {
16
            return new SuccessfulValidationResult();
17
        }
18
    }
19
}
20