FileRule   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 7
c 1
b 0
f 0
dl 0
loc 18
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 12 4
1
<?php
2
3
namespace PhpcsDiff\Filter\Rule;
4
5
use PhpcsDiff\Filter\Rule\Exception\InvalidArgumentException;
6
use PhpcsDiff\Filter\Rule\Exception\RuleException;
7
use PhpcsDiff\Filter\Rule\Exception\RuntimeException;
8
9
class FileRule implements RuleInterface
10
{
11
    /**
12
     * @param mixed $data
13
     * @throws RuleException
14
     */
15
    public function __invoke($data)
16
    {
17
        if (!is_string($data)) {
18
            throw new InvalidArgumentException('The data argument provided is not a string.');
19
        }
20
21
        if (!file_exists($data)) {
22
            throw new RuntimeException('The file provided does not exist.');
23
        }
24
25
        if (!is_file($data)) {
26
            throw new RuntimeException('The file provided is not a regular file.');
27
        }
28
    }
29
}
30