Completed
Push — master ( fb3818...01966b )
by Beñat
02:21
created

TemplateFormRegistry::get()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 15
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 15
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 8
nc 3
nop 1
1
<?php
2
3
/*
4
 * This file is part of the CMS Kernel library.
5
 *
6
 * Copyright (c) 2016 LIN3S <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace LIN3S\CMSKernel\Infrastructure\Web\Symfony\Form;
13
14
/**
15
 * @author Beñat Espiña <[email protected]>
16
 */
17
abstract class TemplateFormRegistry
18
{
19
    abstract public function types();
20
21
    public function get($templateName)
22
    {
23
        foreach ($this->types() as $key => $type) {
24
            if ($key === $templateName) {
25
                return $this->types()[$key];
26
            }
27
        }
28
29
        throw new \LogicException(
30
            sprintf(
31
                'The given "%s" template name does not match with any form type',
32
                $templateName
33
            )
34
        );
35
    }
36
}
37