Completed
Push — components-poc ( 6ce8f4...e1010e )
by
unknown
13:39
created

Directory::set()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 12
rs 9.8666
c 0
b 0
f 0
cc 3
nc 2
nop 1
1
<?php
2
3
namespace League\Plates\Template;
4
5
use LogicException;
6
7
/**
8
 * Default template directory.
9
 */
10
class Directory
11
{
12
    /**
13
     * Template directory path.
14
     * @var string
15
     */
16
    protected $path;
17
18
    /**
19
     * Create new Directory instance.
20
     * @param string $path
21
     */
22
    public function __construct($path = null)
23
    {
24
        $this->set($path);
25
    }
26
27
    /**
28
     * Set path to templates directory.
29
     * @param  string|null $path Pass null to disable the default directory.
30
     * @return Directory
31
     */
32
    public function set($path)
33
    {
34
        if (!is_null($path) and !is_dir($path)) {
35
            throw new LogicException(
36
                'The specified path "' . $path . '" does not exist.'
37
            );
38
        }
39
40
        $this->path = $path;
41
42
        return $this;
43
    }
44
45
    /**
46
     * Get path to templates directory.
47
     * @return string
48
     */
49
    public function get()
50
    {
51
        return $this->path;
52
    }
53
}
54