Completed
Pull Request — master (#5032)
by Grégoire
03:41
created

TemplateRegistry   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 0
dl 0
loc 31
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getTemplates() 0 4 1
A setTemplates() 0 4 1
A getTemplate() 0 6 2
A setTemplate() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Sonata Project package.
7
 *
8
 * (c) Thomas Rabaix <[email protected]>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Sonata\AdminBundle\Templating;
15
16
/**
17
 * @author Timo Bakx <[email protected]>
18
 */
19
final class TemplateRegistry implements MutableTemplateRegistryInterface
20
{
21
    private $templates = [];
22
23
    public function __construct(array $templates = [])
24
    {
25
        $this->templates = $templates;
26
    }
27
28
    public function getTemplates()
29
    {
30
        return $this->templates;
31
    }
32
33
    public function setTemplates(array $templates): void
34
    {
35
        $this->templates = $templates;
36
    }
37
38
    public function getTemplate($name)
39
    {
40
        if (isset($this->templates[$name])) {
41
            return $this->templates[$name];
42
        }
43
    }
44
45
    public function setTemplate($name, $template): void
46
    {
47
        $this->templates[$name] = $template;
48
    }
49
}
50