Completed
Push — master ( 195cac...2c4aac )
by Nazar
05:02
created

False_class::__get()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * @package   CleverStyle Framework
4
 * @author    Nazar Mokrynskyi <[email protected]>
5
 * @copyright Copyright (c) 2011-2017, Nazar Mokrynskyi
6
 * @license   MIT License, see license.txt
7
 */
8
namespace cs;
9
use
10
	ArrayAccess,
11
	SimpleXMLElement;
12
/**
13
 * False_class is used for chained calling, when some method may return false.
14
 *
15
 * Usage of class is simple, just return his instance instead of real boolean <i>false</i>.
16
 * On every call of any method or getting of any property or getting any element of array instance of the this class will be returned.
17
 * Access to anything of this class instance will be casted to boolean <i>false</i>
18
 *
19
 * Inherits SimpleXMLElement in order to be casted from object to boolean as <i>false</i>
20
 *
21
 * @property string $error
22
 */
23
class False_class extends SimpleXMLElement implements ArrayAccess {
24
	/**
25
	 * Use this method to obtain correct instance
26
	 *
27
	 * @return False_class
28
	 */
29 36
	public static function instance () {
30 36
		static $instance;
31 36
		if (!isset($instance)) {
32 36
			$instance = new self('<?xml version=\'1.0\'?><cs></cs>');
33
		}
34 36
		return $instance;
35
	}
36
	/**
37
	 * Getting any property
38
	 *
39
	 * @param string $item
40
	 *
41
	 * @return False_class
42
	 */
43
	public function __get ($item) {
44
		return $this;
45
	}
46
	/**
47
	 * Getting any property
48
	 *
49
	 * @param string $item
50
	 *
51
	 * @return false
52
	 */
53
	public function __isset ($item) {
54
		return false;
55
	}
56
	/**
57
	 * Calling of any method
58
	 *
59
	 * @param string  $method
60
	 * @param mixed[] $params
61
	 *
62
	 * @return False_class
63
	 */
64 2
	public function __call ($method, $params) {
65 2
		return $this;
66
	}
67
	/**
68
	 * Calling as callable
69
	 *
70
	 * @return False_class
71
	 */
72
	public function __invoke () {
73
		return $this;
74
	}
75
	/**
76
	 * @return string
77
	 */
78
	public function __toString () {
79
		return '';
80
	}
81
	/**
82
	 * If item exists
83
	 */
84
	public function offsetExists ($offset) {
85
		return false;
86
	}
87
	/**
88
	 * Get item
89
	 */
90
	public function offsetGet ($offset) {
91
		return $this;
92
	}
93
	/**
94
	 * Set item
95
	 */
96
	public function offsetSet ($offset, $value) { }
97
	/**
98
	 * Delete item
99
	 */
100
	public function offsetUnset ($offset) { }
101
}
102