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

TemplateFormRegistry   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 0
dl 0
loc 20
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
types() 0 1 ?
A get() 0 15 3
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