Completed
Push — master ( ce7b38...6ec792 )
by Peter
04:34
created

Builder::build()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 14
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 14
ccs 0
cts 10
cp 0
rs 9.4285
cc 2
eloc 7
nc 2
nop 1
crap 6
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
namespace GpsLab\Component\Sitemap;
10
11
use GpsLab\Component\Sitemap\Builder\CollectionBuilder;
12
use GpsLab\Component\Sitemap\Result\ResultInterface;
13
use Symfony\Component\Console\Style\SymfonyStyle;
14
15
class Builder
16
{
17
    /**
18
     * @var CollectionBuilder
19
     */
20
    protected $builders;
21
22
    /**
23
     * @var ResultInterface
24
     */
25
    protected $result;
26
27
    /**
28
     * @param CollectionBuilder $builders
29
     * @param ResultInterface $result
30
     */
31
    public function __construct(CollectionBuilder $builders, ResultInterface $result)
32
    {
33
        $this->builders = $builders;
34
        $this->result = $result;
35
    }
36
37
    /**
38
     * @param SymfonyStyle $io
39
     *
40
     * @return int
41
     */
42
    public function build(SymfonyStyle $io)
43
    {
44
        $builders = $this->builders->getBuilders();
45
        $total = count($builders);
46
47
        for ($i = 1; $i <= $total; $i++) {
48
            // show builder number
49
            $io->section(sprintf('[%d/%d] Build for <info>%s</info> builder', $i, $total, $builders[$i]->getTitle()));
50
51
            $builders[$i]->execute($this->result, $io);
52
        }
53
54
        return $this->result->save();
55
    }
56
}
57