ProductionLine::__construct()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 6
rs 10
cc 2
nc 2
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace FSi\Bundle\AdminBundle\Factory;
6
7
use FSi\Bundle\AdminBundle\Admin\Element;
8
9
class ProductionLine
10
{
11
    /**
12
     * @var Worker[]
13
     */
14
    protected $workers;
15
16
    /**
17
     * @param Worker[] $workers
18
     */
19
    public function __construct(array $workers = [])
20
    {
21
        $this->workers = [];
22
23
        foreach((array) $workers as $worker) {
24
            $this->addWorker($worker);
25
        }
26
    }
27
28
    public function addWorker(Worker $worker): void
29
    {
30
        $this->workers[] = $worker;
31
    }
32
33
    public function count(): int
34
    {
35
        return count($this->workers);
36
    }
37
38
    /**
39
     * @return Worker[]
40
     */
41
    public function getWorkers(): array
42
    {
43
        return $this->workers;
44
    }
45
46
    public function workOn(Element $element): void
47
    {
48
        foreach ($this->workers as $worker) {
49
            $worker->mount($element);
50
        }
51
    }
52
}
53