Completed
Push — master ( 0d3592...0bb29a )
by Peter
06:28
created

SilentSitemapBuilder   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 41
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A build() 0 15 3
1
<?php
2
/**
3
 * GpsLab component.
4
 *
5
 * @author    Peter Gribanov <[email protected]>
6
 * @copyright Copyright (c) 2011, Peter Gribanov
7
 * @license   http://opensource.org/licenses/MIT
8
 */
9
10
namespace GpsLab\Component\Sitemap\Builder\Sitemap;
11
12
use GpsLab\Component\Sitemap\Builder\Url\UrlBuilderCollection;
13
use GpsLab\Component\Sitemap\Stream\Stream;
14
15
class SilentSitemapBuilder
16
{
17
    /**
18
     * @var UrlBuilderCollection
19
     */
20
    private $builders;
21
22
    /**
23
     * @var Stream
24
     */
25
    private $stream;
26
27
    /**
28
     * @param UrlBuilderCollection $builders
29
     * @param Stream               $stream
30
     */
31
    public function __construct(UrlBuilderCollection $builders, Stream $stream)
32
    {
33
        $this->builders = $builders;
34
        $this->stream = $stream;
35
    }
36
37
    /**
38
     * @return int
39
     */
40
    public function build()
41
    {
42
        $this->stream->open();
43
44
        foreach ($this->builders as $builder) {
45
            foreach ($builder as $url) {
46
                $this->stream->push($url);
47
            }
48
        }
49
50
        $total_urls = count($this->stream);
51
        $this->stream->close();
52
53
        return $total_urls;
54
    }
55
}
56