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   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 6
c 0
b 0
f 0
lcom 1
cbo 2
dl 0
loc 57
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 2
A add() 0 10 1
A getByProperty() 0 10 2
A keyFromProperty() 0 4 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
}