ViewFactory   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

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
9
class ViewFactory
10
{
11
    private $registry;
12
13
    public function __construct(
14
        TypeRegistry $registry
15
16
    ) {
17
        $this->registry = $registry;
18
    }
19
20
    public function create(string $typeName, $data, array $options): ViewInterface
21
    {
22
        $resolver = new OptionsResolver();
23
        $type = $this->registry->get($typeName);
24
        $type->configureOptions($resolver);
25
26
        $options = $resolver->resolve($options);
27
28
        return $type->createView($this, $data, $options);
29
    }
30
}
31