Completed
Push — master ( 43d6c5...49981b )
by Yuri
02:20
created

TemplateFactory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 62.5%

Importance

Changes 0
Metric Value
dl 0
loc 21
ccs 5
cts 8
cp 0.625
rs 10
c 0
b 0
f 0
wmc 2
lcom 0
cbo 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A create() 0 10 2
1
<?php
2
3
namespace Tamtamchik\SimpleFlash;
4
5
use Tamtamchik\SimpleFlash\Exceptions\FlashTemplateNotFoundException;
6
7
/**
8
 * Class TemplateFactory.
9
 */
10
class TemplateFactory
11
{
12
    /**
13
     * Return template from available list of templates.
14
     *
15
     * @param string $name - available templates: bootstrap3, bootstrap4, foundation5, foundation6, semantic2, uikit2
16
     *
17
     * @return TemplateInterface
18
     * @throws FlashTemplateNotFoundException
19
     */
20 82
    public static function create($name = Templates::BASE)
21
    {
22 82
        $class = __NAMESPACE__ . '\\Templates\\' . ucwords($name) . 'Template';
23
24 82
        if (class_exists($class)) {
25 80
            return new $class();
26
        }
27
28 2
        throw new FlashTemplateNotFoundException("Template \"{$name}\" not found!");
29
    }
30
}
31