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

Compatibility::next()   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\Request;
9
10
/**
11
 * Trait is here only to provide compatibility when request object is passed as first argument into controller
12
 *
13
 * @todo Remove in 4.x
14
 */
15
trait Compatibility {
16
	/**
17
	 * @param string $index
18
	 *
19
	 * @return bool
20
	 */
21
	function offsetExists ($index) {
22
		return isset($this->route_ids[$index]);
23
	}
24
	/**
25
	 * @param string $index
26
	 *
27
	 * @return mixed
28
	 */
29
	function &offsetGet ($index) {
30
		return $this->route_ids[$index];
31
	}
32
	/**
33
	 * @param string $index
34
	 * @param mixed  $value
35
	 */
36
	function offsetSet ($index, $value) {
37
		$this->route_ids[$index] = $value;
38
	}
39
	/**
40
	 * @param string $index
41
	 */
42
	public function offsetUnset ($index) {
43
		unset($this->route_ids[$index]);
44
	}
45
	/**
46
	 * @return mixed Can return any type.
47
	 */
48
	public function current () {
49
		return current($this->route_ids);
50
	}
51
	public function next () {
52
		next($this->route_ids);
53
	}
54
	/**
55
	 * @return mixed scalar on success, or null on failure.
56
	 */
57
	public function key () {
58
		return key($this->route_ids);
59
	}
60
	/**
61
	 * @return boolean The return value will be casted to boolean and then evaluated.
62
	 * Returns true on success or false on failure.
63
	 */
64
	public function valid () {
65
		return $this->key() !== null;
66
	}
67
	public function rewind () {
68
		reset($this->route_ids);
69
	}
70
}
71