FileExists   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 11
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A validate() 0 9 3
1
<?php
2
3
namespace kalanis\kw_rules\Rules\File;
4
5
6
use kalanis\kw_rules\Interfaces\IValidateFile;
7
use kalanis\kw_rules\Exceptions\RuleException;
8
9
10
/**
11
 * Class FileExists
12
 * @package kalanis\kw_rules\Rules\File
13
 * Check if input file exists
14
 */
15
class FileExists extends AFileRule
16
{
17 2
    public function validate(IValidateFile $entry): void
18
    {
19 2
        $filename = $entry->getTempName();
20 2
        if (!empty($filename)) {
21 1
            if (is_file($filename)) {
22 1
                return;
23
            }
24
        }
25 1
        throw new RuleException($this->errorText);
26
    }
27
}
28