RelationCollection::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
declare(strict_types = 1);
4
5
/*
6
 * This file is part of the FiveLab Resource package
7
 *
8
 * (c) FiveLab
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code
12
 */
13
14
namespace FiveLab\Component\Resource\Resource\Relation;
15
16
/**
17
 * The collection for store relations.
18
 *
19
 * @author Vitaliy Zhuk <[email protected]>
20
 */
21
class RelationCollection implements \IteratorAggregate, \Countable
22
{
23
    /**
24
     * @var array|RelationInterface[]
25
     */
26
    private $relations;
27
28
    /**
29
     * Constructor.
30
     *
31
     * @param RelationInterface ...$relations
32
     */
33 12
    public function __construct(RelationInterface ...$relations)
0 ignored issues
show
Unused Code introduced by
The parameter $relations is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
34
    {
35 12
        $this->relations = func_get_args();
36 12
    }
37
38
    /**
39
     * {@inheritdoc}
40
     *
41
     * @return \ArrayIterator|RelationInterface[]
42
     */
43 3
    public function getIterator(): \ArrayIterator
44
    {
45 3
        return new \ArrayIterator($this->relations);
46
    }
47
48
    /**
49
     * {@inheritdoc}
50
     */
51 7
    public function count(): int
52
    {
53 7
        return \count($this->relations);
54
    }
55
}
56