Test Failed
Push — master ( d5e6e0...328550 )
by Charis
07:06
created

AbstractRenderer::getIterator()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
nc 1
cc 1
eloc 2
nop 0
1
<?php
2
3
namespace Resilient;
4
5
use \Psr\Http\Message\ResponseInterface;
6
7
/**
8
 * Abstract AbstractRenderer class.
9
 *
10
 * @abstract
11
 */
12
abstract class AbstractRenderer implements \ArrayAccess
13
{
14
15
	protected $offset = [];
16
17
	/**
18
	 * template function.
19
	 *
20
	 * @access protected
21
	 * @abstract
22
	 * @param mixed $template
23
	 */
24
	abstract protected function template($template);
25
26
	/**
27
	 * render function.
28
	 *
29
	 * @access public
30
	 * @abstract
31
	 * @param ResponseInterface $response
32
	 * @param mixed $template
33
	 * @param mixed $data (default: [])
34
	 * @return ResponseInterface
35
	 */
36
	abstract public function render(ResponseInterface $response, $template, $data = []);
37
38
    /**
39
     * merge_data function.
40
     *
41
     * @access protected
42
     * @param mixed $data
43
     * @return array
44
     */
45
    protected function merge_data($data)
46
	{
47
		return array_merge($this->offset, $data);
48
	}
49
50
	/**
51
	 * loadConfig function.
52
	 *
53
	 * @access public
54
	 * @param array $offset
55
	 * @return $this
56
	 */
57
	public function loadConfig(array $offset)
58
	{
59
    	$this->offset = $this->merge_data($offset);
60
61
    	return $this;
62
	}
63
64
	/**
65
	 * ArrayAccess Implementations
66
	 */
67
68
	/**
69
     * {@inheritdoc}
70
     */
71
    public function offsetExists($key)
72
    {
73
        return array_key_exists($key, $this->offset);
74
    }
75
76
    /**
77
     * {@inheritdoc}
78
     */
79
    public function offsetGet($key)
80
    {
81
        return $this->offset[$key];
82
    }
83
84
    /**
85
     * {@inheritdoc}
86
     */
87
    public function offsetSet($key, $value)
88
    {
89
        $this->offset[$key] = $value;
90
    }
91
92
    /**
93
     * {@inheritdoc}
94
     */
95
    public function offsetUnset($key)
96
    {
97
        unset($this->offset[$key]);
98
    }
99
100
    /**
101
     * {@inheritdoc}
102
     */
103
    public function count()
104
    {
105
        return count($this->offset);
106
    }
107
108
    /**
109
     * {@inheritdoc}
110
     */
111
    public function getIterator()
112
    {
113
        return new \ArrayIterator($this->offset);
114
    }
115
116
}
117