Completed
Pull Request — master (#36)
by Daniel
02:33
created

ViewBuilder   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A add() 0 4 1
A create() 0 4 1
A setValue() 0 4 1
A getView() 0 4 1
1
<?php
2
3
namespace Psi\Component\ContentType\View;
4
5
use Psi\Component\ContentType\View\View;
6
7
class ViewBuilder
8
{
9
    private $view;
10
    private $factory;
11
12
    public function __construct(ViewFactory $factory, View $view)
13
    {
14
        $this->factory = $factory;
15
        $this->view = $view;
16
    }
17
18
    public function add(string $name, string $fieldType, $data, array $options)
19
    {
20
        $this->view[$name] = $this->create($fieldType, $data, $options);
21
    }
22
23
    public function create(string $fieldType, $data, array $options)
24
    {
25
        return $this->factory->createView($fieldType, $data, $options);
26
    }
27
28
    public function setValue($value)
29
    {
30
        $this->view->setValue($value);
31
    }
32
33
    public function getView()
34
    {
35
        return $this->view;
36
    }
37
}
38