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

StemplerSource   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 39
rs 10
c 0
b 0
f 0
wmc 3
lcom 1
cbo 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getFilename() 0 4 1
A getSource() 0 4 1
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
}