Completed
Branch full-rewrite (4754d3)
by Thibaud
03:13
created

PackageBuilder::addResource()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace Alchemy\Zippy\Package;
4
5
use Alchemy\Zippy\Resource\ResourceUri;
6
use Traversable;
7
8
class PackageBuilder extends Package implements \IteratorAggregate
9
{
10
    /**
11
     * @var ResourceUri[]
12
     */
13
    private $resources = [];
14
15
    /**
16
     * @param ResourceUri $resource
17
     */
18
    public function addResource(ResourceUri $resource)
19
    {
20
        $this->resources[] = $resource;
21
    }
22
23
    /**
24
     * (PHP 5 &gt;= 5.0.0)<br/>
25
     * Retrieve an external iterator
26
     * @link http://php.net/manual/en/iteratoraggregate.getiterator.php
27
     * @return Traversable An instance of an object implementing <b>Iterator</b> or
28
     * <b>Traversable</b>
29
     */
30
    public function getIterator()
31
    {
32
        return new \ArrayIterator(array_merge(iterator_to_array(parent::getIterator()), $this->resources));
33
    }
34
}
35