Passed
Push — master ( e1d378...f1a11e )
by Vitaliy
11:08 queued 21s
created

ResourceCollection::valid()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 4
Ratio 100 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 4
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
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;
15
16
/**
17
 * The collection for store resources.
18
 *
19
 * @author Vitaliy Zhuk <[email protected]>
20
 */
21
class ResourceCollection extends AbstractResourceSupport implements \IteratorAggregate, \Countable
22
{
23
    /**
24
     * @var ResourceInterface[]
25
     */
26
    private $resources;
27
28
    /**
29
     * Constructor.
30
     *
31
     * @param ResourceInterface ...$resources
32
     */
33 8
    public function __construct(ResourceInterface ...$resources)
34
    {
35 8
        parent::__construct();
36
37 8
        $this->resources = func_get_args();
38 8
    }
39
40
    /**
41
     * {@inheritdoc}
42
     *
43
     * @return \ArrayIterator|ResourceInterface[]
44
     */
45 6
    public function getIterator(): \ArrayIterator
46
    {
47 6
        return new \ArrayIterator($this->resources);
48
    }
49
50
    /**
51
     * {@inheritdoc}
52
     */
53 2
    public function count(): int
54
    {
55 2
        return \count($this->resources);
56
    }
57
}
58