Passed
Push — develop ( 119dfd...2d7b42 )
by Brent
02:44
created

HeaderCompilerFactory   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 51
rs 10
c 0
b 0
f 0
wmc 4
lcom 1
cbo 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A setEnvironment() 0 5 1
A addHeaderCompiler() 0 5 1
A getHeaderCompilerByEnvironment() 0 3 1
1
<?php
2
3
namespace Brendt\Stitcher\Factory;
4
5
use Brendt\Stitcher\Site\Http\HeaderCompiler;
6
7
class HeaderCompilerFactory
8
{
9
    /**
10
     * @var string
11
     */
12
    private $environment;
13
14
    /**
15
     * @var HeaderCompiler[]
16
     */
17
    private $headerCompilers = [];
18
19
    /**
20
     * HeaderCompilerFactory constructor.
21
     *
22
     * @param string $environment
23
     */
24
    function __construct(string $environment) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
25
        $this->environment = $environment;
26
    }
27
28
    /**
29
     * @param string $environment
30
     *
31
     * @return HeaderCompilerFactory
32
     */
33
    public function setEnvironment(string $environment) : HeaderCompilerFactory {
34
        $this->environment = $environment;
35
36
        return $this;
37
    }
38
39
    /**
40
     * @param string         $environment
41
     * @param HeaderCompiler $headerCompiler
42
     *
43
     * @return HeaderCompilerFactory
44
     */
45
    public function addHeaderCompiler(string $environment, HeaderCompiler $headerCompiler) : HeaderCompilerFactory {
46
        $this->headerCompilers[$environment] = $headerCompiler;
47
48
        return $this;
49
    }
50
51
    /**
52
     * @return HeaderCompiler|null
53
     */
54
    public function getHeaderCompilerByEnvironment() : ?HeaderCompiler {
55
        return $this->headerCompilers[$this->environment] ?? null;
56
    }
57
}
58