Completed
Push — master ( d7d461...570560 )
by Nazar
05:30 queued 01:12
created

Compatibility::rewind()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
/**
3
 * @package   CleverStyle CMS
4
 * @author    Nazar Mokrynskyi <[email protected]>
5
 * @copyright Copyright (c) 2016, Nazar Mokrynskyi
6
 * @license   MIT License, see license.txt
7
 */
8
namespace cs\Response;
9
use
10
	cs\Request;
11
12
/**
13
 * Trait is here only to provide compatibility when response object is passed as second argument into controller
14
 *
15
 * @todo Remove in 4.x
16
 */
17
trait Compatibility {
18
	/**
19
	 * @param string $index
20
	 *
21
	 * @return bool
22
	 */
23
	function offsetExists ($index) {
24
		return isset(Request::instance()->route_path[$index]);
25
	}
26
	/**
27
	 * @param string $index
28
	 *
29
	 * @return mixed
30
	 */
31
	function &offsetGet ($index) {
32
		return Request::instance()->route_path[$index];
33
	}
34
	/**
35
	 * @param string $index
36
	 * @param mixed  $value
37
	 */
38
	function offsetSet ($index, $value) {
39
		Request::instance()->route_path[$index] = $value;
40
	}
41
	/**
42
	 * @param string $index
43
	 */
44
	public function offsetUnset ($index) {
45
		unset(Request::instance()->route_path[$index]);
46
	}
47
	/**
48
	 * @return mixed Can return any type.
49
	 */
50
	public function current () {
51
		return current(Request::instance()->route_path);
52
	}
53
	public function next () {
54
		next(Request::instance()->route_path);
55
	}
56
	/**
57
	 * @return mixed scalar on success, or null on failure.
58
	 */
59
	public function key () {
60
		return key(Request::instance()->route_path);
61
	}
62
	/**
63
	 * @return boolean The return value will be casted to boolean and then evaluated.
64
	 * Returns true on success or false on failure.
65
	 */
66
	public function valid () {
67
		return $this->key() !== null;
68
	}
69
	public function rewind () {
70
		reset(Request::instance()->route_path);
71
	}
72
}
73