Folders   A
last analyzed

Coupling/Cohesion

Components 1
Dependencies 1

Complexity

Total Complexity 7

Size/Duplication

Total Lines 66
Duplicated Lines 0 %

Test Coverage

Coverage 59.26%

Importance

Changes 0
Metric Value
wmc 7
c 0
b 0
f 0
lcom 1
cbo 1
dl 0
loc 66
ccs 16
cts 27
cp 0.5926
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A add() 0 10 2
A remove() 0 10 2
A get() 0 8 2
A exists() 0 4 1
1
<?php
2
3
namespace League\Plates\Template;
4
5
use LogicException;
6
7
/**
8
 * A collection of template folders.
9
 */
10
class Folders
11
{
12
    /**
13
     * Array of template folders.
14
     * @var array
15
     */
16
    protected $folders = array();
17
18
    /**
19
     * Add a template folder.
20
     * @param  string  $name
21
     * @param  string  $path
22
     * @param  boolean $fallback
23
     * @return Folders
24
     */
25 54
    public function add($name, $path, $fallback = false)
26
    {
27 54
        if ($this->exists($name)) {
28 4
            throw new LogicException('The template folder "' . $name . '" is already being used.');
29
        }
30
31 54
        $this->folders[$name] = new Folder($name, $path, $fallback);
32
33 50
        return $this;
34
    }
35
36
    /**
37
     * Remove a template folder.
38
     * @param  string  $name
39
     * @return Folders
40
     */
41 6
    public function remove($name)
42
    {
43 6
        if (!$this->exists($name)) {
44 2
            throw new LogicException('The template folder "' . $name . '" was not found.');
45
        }
46
47 4
        unset($this->folders[$name]);
48
49 4
        return $this;
50
    }
51
52
    /**
53
     * Get a template folder.
54
     * @param  string $name
55
     * @return Folder
56
     */
57 18
    public function get($name)
58
    {
59 18
        if (!$this->exists($name)) {
60 2
            throw new LogicException('The template folder "' . $name . '" was not found.');
61
        }
62
63 16
        return $this->folders[$name];
64
    }
65
66
    /**
67
     * Check if a template folder exists.
68
     * @param  string  $name
69
     * @return boolean
70
     */
71 58
    public function exists($name)
72
    {
73 58
        return isset($this->folders[$name]);
74
    }
75
}
76