GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

PHPPropertyFile::fromFileInfo()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 11
rs 9.4285
cc 2
eloc 6
nc 2
nop 1
1
<?php
2
3
namespace UCD\Infrastructure\Repository\CharacterRepository\FileRepository\PropertyFile;
4
5
use UCD\Exception\InvalidArgumentException;
6
use UCD\Infrastructure\Repository\CharacterRepository\FileRepository\File\PHPFile;
7
use UCD\Infrastructure\Repository\CharacterRepository\FileRepository\Property;
8
use UCD\Infrastructure\Repository\CharacterRepository\FileRepository\PropertyFile;
9
10
class PHPPropertyFile extends PropertyFile
11
{
12
    const FILE_NAME_REGEX  = '/^(?P<type>[A-Za-z_-]+)\.php\.gz$/';
13
    const FILE_PATH_FORMAT = '%s/%s.php.gz';
14
15
    /**
16
     * @param \SplFileInfo $fileInfo
17
     * @return PHPPropertyFile
18
     * @throws InvalidArgumentException
19
     */
20
    public static function fromFileInfo(\SplFileInfo $fileInfo)
21
    {
22
        if (preg_match(self::FILE_NAME_REGEX, $fileInfo->getBasename(), $matches) !== 1) {
23
            throw new InvalidArgumentException();
24
        }
25
26
        $file = new PHPFile($fileInfo);
27
        $property = Property::ofType($matches['type']);
28
29
        return new self($file, $property);
30
    }
31
32
    /**
33
     * @param \SplFileInfo $basePath
34
     * @param Property $property
35
     * @return self
36
     */
37
    public static function fromProperty(\SplFileInfo $basePath, Property $property)
38
    {
39
        $filePath = sprintf(self::FILE_PATH_FORMAT, $basePath->getPathname(), $property);
40
        $fileInfo = new \SplFileInfo($filePath);
41
        $file = new PHPFile($fileInfo);
42
43
        return new self($file, $property);
44
    }
45
}