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

CellFactory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A create() 0 10 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Psi\Component\View;
6
7
use Symfony\Component\OptionsResolver\OptionsResolver;
8
use Psi\Component\View\TypeRegistry;
9
10
class CellFactory
11
{
12
    private $registry;
13
14
    public function __construct(
15
        TypeRegistry $registry
16
17
    ) {
18
        $this->registry = $registry;
19
    }
20
21
    public function create(string $typeName, $data, array $options): ViewInterface
22
    {
23
        $resolver = new OptionsResolver();
24
        $type = $this->registry->get($typeName);
25
        $type->configureOptions($resolver);
26
27
        $options = $resolver->resolve($options);
28
29
        return $type->createView($this, $data, $options);
30
    }
31
}
32
33