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

PackageBuilder   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 27
wmc 2
lcom 1
cbo 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A addResource() 0 4 1
A getIterator() 0 4 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