PhpFileRule   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 6
c 1
b 0
f 0
dl 0
loc 16
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 10 3
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