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.

ResourceCollection::__construct()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 3.2098

Importance

Changes 0
Metric Value
dl 0
loc 9
ccs 5
cts 7
cp 0.7143
rs 9.6666
c 0
b 0
f 0
cc 3
eloc 5
nc 3
nop 1
crap 3.2098
1
<?php
2
namespace Solvire\API\JSONSchema;
3
4
use PhpCollection\Sequence;
5
6
/**
7
 *
8
 * @author solvire <[email protected]>
9
 * @package JSONSchema
10
 * @namespace Solvire\API\JSONSchema
11
 */
12
class ResourceCollection extends Sequence
13
{
14
15
    /**
16
     *
17
     *
18
     * There isn't much to ordering here.
19
     * Just use a numeric key and we will try tro sort later
20
     *
21
     * @param array $resources            
22
     */
23 3
    public function __construct($resources = [])
24
    {
25 3
        foreach ($resources as $key => $resource) {
26
            if (! ($resource instanceof Resource)) {
27
                throw new \RuntimeException("Only Resource objects allowed here.");
28
            }
29 3
        }
30 3
        parent::__construct($resources);
31 3
    }
32
33
    /**
34
     *
35
     * @return array
36
     */
37
    public function toArray()
38
    {
39
        return $this->all();
40
    }
41
42
    /**
43
     *
44
     * @param Resource $resource            
45
     * @throws \RuntimeException
46
     */
47
    public function add($resource)
48
    {
49
        if (! ($resource instanceof Resource)) {
50
            throw new \RuntimeException("Only Resource objects allowed here.");
51
        }
52
        return parent::add($resource);
53
    }
54
}
55