Completed
Pull Request — master (#244)
by Łukasz
11:47
created

ElementCollectionVisitor   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 29
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A visitManager() 0 7 2
1
<?php
2
3
/**
4
 * (c) FSi sp. z o.o. <[email protected]>
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
namespace FSi\Bundle\AdminBundle\Admin\Manager;
11
12
use FSi\Bundle\AdminBundle\Admin\Manager;
13
use FSi\Bundle\AdminBundle\Admin\ManagerInterface;
14
use FSi\Bundle\AdminBundle\Factory\ProductionLine;
15
16
class ElementCollectionVisitor implements Visitor
17
{
18
    /**
19
     * @var array
20
     */
21
    private $elements;
22
23
    /**
24
     * @var \FSi\Bundle\AdminBundle\Factory\ProductionLine
25
     */
26
    private $factoryProductionLine;
27
28
    public function __construct($elements = array(), ProductionLine $factoryProductionLine)
29
    {
30
        $this->elements = $elements;
31
        $this->factoryProductionLine = $factoryProductionLine;
32
    }
33
34
    /**
35
     * @param ManagerInterface $manager
36
     */
37
    public function visitManager(ManagerInterface $manager)
38
    {
39
        foreach ($this->elements as $element) {
40
            $this->factoryProductionLine->workOn($element);
41
            $manager->addElement($element);
42
        }
43
    }
44
}
45