BusinessTemplateChain   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 0
dl 0
loc 40
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A addBusinessTemplate() 0 4 1
A getBusinessTemplate() 0 8 2
A getBusinessTemplates() 0 4 1
1
<?php
2
3
namespace Victoire\Bundle\BusinessPageBundle\Chain;
4
5
use Victoire\Bundle\BusinessPageBundle\Entity\BusinessTemplate;
6
7
/**
8
 * BusinessTemplate chain.
9
 */
10
class BusinessTemplateChain
11
{
12
    private $patterns;
13
14
    public function __construct()
0 ignored issues
show
introduced by
Missing function doc comment
Loading history...
15
    {
16
        $this->patterns = [];
17
    }
18
19
    /**
0 ignored issues
show
introduced by
Doc comment for parameter "$alias" missing
Loading history...
20
     * @param BusinessTemplate $pattern
21
     * @param $alias
0 ignored issues
show
introduced by
Missing parameter name
Loading history...
22
     */
23
    public function addBusinessTemplate(BusinessTemplate $pattern, $alias)
24
    {
25
        $this->patterns[$alias] = $pattern;
26
    }
27
28
    /**
29
     * @param string $alias
30
     *
31
     * @return BusinessTemplate
32
     */
33
    public function getBusinessTemplate($alias)
34
    {
35
        if (array_key_exists($alias, $this->patterns)) {
36
            return $this->patterns[$alias];
37
        }
38
39
        return $this->patterns['default'];
40
    }
41
42
    /**
43
     * @return array
44
     */
45
    public function getBusinessTemplates()
46
    {
47
        return $this->patterns;
48
    }
49
}
50