Layout::helper()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
3
namespace Staticka;
4
5
use Staticka\Contracts\LayoutContract;
6
use Staticka\Contracts\FilterContract;
7
use Staticka\Contracts\HelperContract;
8
9
/**
10
 * Layout
11
 *
12
 * @package Staticka
13
 * @author  Rougin Gutib <[email protected]>
14
 */
15
class Layout implements LayoutContract
16
{
17
    /**
18
     * @var string
19
     */
20
    protected $body = self::BODY_DEFAULT;
21
22
    /**
23
     * @var array
24
     */
25
    protected $filters = array();
26
27
    /**
28
     * @var array
29
     */
30
    protected $helpers = array();
31
32
    /**
33
     * @var string $body
34
     */
35 27
    public function __construct($body = self::BODY_DEFAULT)
36
    {
37 27
        $this->body = $body;
38 27
    }
39
40
    /**
41
     * Returns the body content of the layout if available.
42
     *
43
     * @return string
44
     */
45 15
    public function body()
46
    {
47 15
        return $this->body;
48
    }
49
50
    /**
51
     * Adds a filter instance in the layout.
52
     *
53
     * @param  \Staticka\Contracts\FilterContract $filter
54
     * @return self
55
     */
56 6
    public function filter(FilterContract $filter)
57
    {
58 6
        $this->filters[] = $filter;
59 6
    }
60
61
    /**
62
     * Returns all available filters.
63
     *
64
     * @return \Staticka\Contracts\FilterContract[]
65
     */
66 18
    public function filters()
67
    {
68 18
        return $this->filters;
69
    }
70
71
    /**
72
     * Adds a helper instance in the layout.
73
     *
74
     * @param  \Staticka\Contracts\HelperContract $helper
75
     * @return self
76
     */
77 6
    public function helper(HelperContract $helper)
78
    {
79 6
        $this->helpers[$helper->name()] = $helper;
80 6
    }
81
82
    /**
83
     * Returns all available helpers.
84
     *
85
     * @return \Staticka\Contracts\HelperContract[]
86
     */
87 18
    public function helpers()
88
    {
89 18
        return $this->helpers;
90
    }
91
}
92