FileRule::__invoke()   A
last analyzed

Complexity

Conditions 4
Paths 4

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 12
rs 10
cc 4
nc 4
nop 1
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