SilentSitemapBuilder::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 5
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
crap 1
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 1
    public function __construct(UrlBuilderCollection $builders, Stream $stream)
32
    {
33 1
        $this->builders = $builders;
34 1
        $this->stream = $stream;
35 1
    }
36
37
    /**
38
     * @return int
39
     */
40 1
    public function build()
41
    {
42 1
        $this->stream->open();
43
44 1
        foreach ($this->builders as $builder) {
45 1
            foreach ($builder as $url) {
46 1
                $this->stream->push($url);
47
            }
48
        }
49
50 1
        $total_urls = count($this->stream);
51 1
        $this->stream->close();
52
53 1
        return $total_urls;
54
    }
55
}
56