Directory   A
last analyzed

↳ Parent: Project

Coupling/Cohesion

Components 1
Dependencies 0

Complexity

Total Complexity 5

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 0
dl 0
loc 44
ccs 12
cts 12
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A set() 0 12 3
A get() 0 4 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 336
    public function __construct($path = null)
23
    {
24 336
        $this->set($path);
25 336
    }
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 336
    public function set($path)
33
    {
34 336
        if (!is_null($path) and !is_dir($path)) {
35 8
            throw new LogicException(
36 8
                'The specified path "' . $path . '" does not exist.'
37 4
            );
38
        }
39
40 336
        $this->path = $path;
41
42 336
        return $this;
43
    }
44
45
    /**
46
     * Get path to templates directory.
47
     * @return string
48
     */
49 164
    public function get()
50
    {
51 164
        return $this->path;
52
    }
53
}
54