Completed
Push — master ( be7e90...e1942b )
by Anton
03:20
created

StemplerSource::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 2
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/**
3
 * components
4
 *
5
 * @author    Wolfy-J
6
 */
7
8
namespace Spiral\Stempler;
9
10
/**
11
 * Default implementation for ContextInterface.
12
 */
13
final class StemplerSource
14
{
15
    /**
16
     * Must be local stream.
17
     *
18
     * @var string
19
     */
20
    private $filename;
21
22
    /**
23
     * @var null|string
24
     */
25
    private $source = null;
26
27
    /**
28
     * @param string $filename
29
     */
30
    public function __construct(string $filename, string $source = null)
31
    {
32
        $this->filename = $filename;
33
        $this->source = $source;
34
    }
35
36
    /**
37
     * {@inheritdoc}
38
     */
39
    public function getFilename(): string
40
    {
41
        return $this->filename;
42
    }
43
44
    /**
45
     * {@inheritdoc}
46
     */
47
    public function getSource(): string
48
    {
49
        return $this->source ?? file_get_contents($this->filename);
50
    }
51
}