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

ViewBuilder::create()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 3
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