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

getHeaderCompilerByEnvironment()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
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