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

Complexity

Total Complexity 6

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 38.46%

Importance

Changes 0
Metric Value
wmc 6
lcom 0
cbo 1
dl 0
loc 43
ccs 5
cts 13
cp 0.3846
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 3
A toArray() 0 4 1
A add() 0 7 2
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