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

Compatibility   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 9
c 1
b 0
f 0
lcom 0
cbo 1
dl 0
loc 56
rs 10

9 Methods

Rating   Name   Duplication   Size   Complexity  
A offsetExists() 0 3 1
A offsetGet() 0 3 1
A offsetSet() 0 3 1
A offsetUnset() 0 3 1
A current() 0 3 1
A next() 0 3 1
A key() 0 3 1
A valid() 0 3 1
A rewind() 0 3 1
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