Layout   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 75
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 10
c 2
b 0
f 0
dl 0
loc 75
ccs 15
cts 15
cp 1
rs 10
wmc 6

6 Methods

Rating   Name   Duplication   Size   Complexity  
A body() 0 3 1
A filters() 0 3 1
A filter() 0 3 1
A helpers() 0 3 1
A __construct() 0 3 1
A helper() 0 3 1
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