Page   A
last analyzed

Complexity

Total Complexity 11

Size/Duplication

Total Lines 103
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 3
Bugs 0 Features 0
Metric Value
eloc 19
c 3
b 0
f 0
dl 0
loc 103
ccs 30
cts 30
cp 1
rs 10
wmc 11

7 Methods

Rating   Name   Duplication   Size   Complexity  
A data() 0 3 1
A layout() 0 3 1
A helpers() 0 3 1
A filters() 0 3 1
A filter() 0 5 1
A helper() 0 5 1
A __construct() 0 19 5
1
<?php
2
3
namespace Staticka;
4
5
use Staticka\Contracts\FilterContract;
6
use Staticka\Contracts\HelperContract;
7
use Staticka\Contracts\LayoutContract;
8
use Staticka\Contracts\PageContract;
9
10
/**
11
 * Page
12
 *
13
 * @package Staticka
14
 * @author  Rougin Gutib <[email protected]>
15
 */
16
class Page implements PageContract
17
{
18
    /**
19
     * @var array
20
     */
21
    protected $data = array();
22
23
    /**
24
     * @var \Staticka\Contracts\LayoutContract
25
     */
26
    protected $layout;
27
28
    /**
29
     * @param \Staticka\Contracts\LayoutContract $layout
30
     * @param array                              $data
31
     */
32 21
    public function __construct(LayoutContract $layout, $data = array())
33
    {
34 21
        $this->data = (array) $data;
35
36 21
        $this->layout = $layout;
37
38 21
        if (isset($data['filters']))
39 7
        {
40 3
            foreach ($data['filters'] as $filter)
41
            {
42 3
                $this->filter($filter);
43 1
            }
44 1
        }
45
46 21
        if (isset($data['helpers']))
47 7
        {
48 3
            foreach ($data['helpers'] as $helper)
49
            {
50 3
                $this->helper($helper);
51 1
            }
52 1
        }
53 21
    }
54
55
    /**
56
     * Returns the details of the page instance.
57
     *
58
     * @return array
59
     */
60 18
    public function data()
61
    {
62 18
        return $this->data;
63
    }
64
65
    /**
66
     * Adds a filter instance in the layout.
67
     *
68
     * @param  \Staticka\Contracts\FilterContract $filter
69
     * @return self
70
     */
71 3
    public function filter(FilterContract $filter)
72
    {
73 3
        $this->layout->filter($filter);
74
75 3
        return $this;
76
    }
77
78
    /**
79
     * Returns all available filters.
80
     *
81
     * @return \Staticka\Contracts\FilterContract[]
82
     */
83 18
    public function filters()
84
    {
85 18
        return $this->layout->filters();
86
    }
87
88
    /**
89
     * Adds a helper instance in the layout.
90
     *
91
     * @param  \Staticka\Contracts\HelperContract $helper
92
     * @return self
93
     */
94 3
    public function helper(HelperContract $helper)
95
    {
96 3
        $this->layout->helper($helper);
97
98 3
        return $this;
99
    }
100
101
    /**
102
     * Returns all available helpers.
103
     *
104
     * @return \Staticka\Contracts\HelperContract[]
105
     */
106 18
    public function helpers()
107
    {
108 18
        return $this->layout->helpers();
109
    }
110
111
    /**
112
     * Returns the layout instance.
113
     *
114
     * @return \Staticka\Contracts\LayoutContract
115
     */
116 15
    public function layout()
117
    {
118 15
        return $this->layout;
119
    }
120
}
121