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

Builder   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 1
cbo 4
dl 0
loc 42
ccs 0
cts 15
cp 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A build() 0 14 2
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