Code Duplication    Length = 20-22 lines in 2 locations

src/View/TypeFactory.php 1 location

@@ 9-28 (lines=20) @@
6
7
use Symfony\Component\OptionsResolver\OptionsResolver;
8
9
class TypeFactory
10
{
11
    private $typeRegistry;
12
13
    public function __construct(
14
        TypeRegistry $typeRegistry
15
    ) {
16
        $this->typeRegistry = $typeRegistry;
17
    }
18
19
    public function create(string $typeName, $data, array $options): ViewInterface
20
    {
21
        $type = $this->typeRegistry->get($typeName);
22
        $resolver = new OptionsResolver();
23
        $type->configureOptions($resolver);
24
        $options = $resolver->resolve($options);
25
26
        return $type->createView($this, $data, $options);
27
    }
28
}
29

src/View/ViewFactory.php 1 location

@@ 9-30 (lines=22) @@
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 $viewName, $data, array $options): ViewInterface
21
    {
22
        $resolver = new OptionsResolver();
23
        $type = $this->registry->get($viewName);
24
        $type->configureOptions($resolver);
25
26
        $options = $resolver->resolve($options);
27
28
        return $type->createView($this, $data, $options);
29
    }
30
}
31