PhpFileRule::__invoke()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 10
rs 10
cc 3
nc 3
nop 1
1
<?php
2
3
namespace PhpcsDiff\Filter\Rule;
4
5
use PhpcsDiff\Filter\Rule\Exception\RuleException;
6
use PhpcsDiff\Filter\Rule\Exception\RuntimeException;
7
8
class PhpFileRule extends FileRule
9
{
10
    /**
11
     * @param mixed $data
12
     * @throws RuleException
13
     */
14
    public function __invoke($data)
15
    {
16
        parent::__invoke($data);
17
18
        if ('.php' !== substr($data, -4)) {
19
            throw new RuntimeException('The file provided does not have a .php extension.');
20
        }
21
22
        if ('text/x-php' !== mime_content_type($data)) {
23
            throw new RuntimeException('The file provided does not have the text/x-php mime type.');
24
        }
25
    }
26
}
27