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.

PropertyFiles::add()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 10
rs 9.4285
cc 1
eloc 5
nc 1
nop 1
1
<?php
2
3
namespace UCD\Infrastructure\Repository\CharacterRepository\FileRepository;
4
5
use UCD\Exception\UnexpectedValueException;
6
7
class PropertyFiles
8
{
9
    /**
10
     * @var PropertyFile[]
11
     */
12
    private $files = [];
13
14
    /**
15
     * @param array $files
16
     */
17
    public function __construct(array $files = [])
18
    {
19
        foreach ($files as $file) {
20
            $this->add($file);
21
        }
22
    }
23
24
    /**
25
     * @param PropertyFile $file
26
     * @return PropertyFile
27
     */
28
    public function add(PropertyFile $file)
29
    {
30
        $key = $this->keyFromProperty(
31
            $file->getProperty()
32
        );
33
34
        $this->files[$key] = $file;
35
36
        return $file;
37
    }
38
39
    /**
40
     * @param Property $property
41
     * @return PropertyFile
42
     * @throws UnexpectedValueException
43
     */
44
    public function getByProperty(Property $property)
45
    {
46
        $key = $this->keyFromProperty($property);
47
48
        if (!array_key_exists($key, $this->files)) {
49
            throw new UnexpectedValueException();
50
        }
51
52
        return $this->files[$key];
53
    }
54
55
    /**
56
     * @param Property $property
57
     * @return string
58
     */
59
    private function keyFromProperty(Property $property)
60
    {
61
        return (string)$property;
62
    }
63
}