Completed
Push — master ( 215c97...c1aac3 )
by Nazar
04:30
created

False_class::__call()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 2
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
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-2016, 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 14
	static function instance () {
30 14
		static $instance;
31 14
		if (!isset($instance)) {
32 14
			$instance = new self('<?xml version=\'1.0\'?><cs></cs>');
33
		}
34 14
		return $instance;
35
	}
36
	/**
37
	 * Getting any property
38
	 *
39
	 * @param string $item
40
	 *
41
	 * @return False_class
42
	 */
43
	function __get ($item) {
44
		return $this;
45
	}
46
	/**
47
	 * Getting any property
48
	 *
49
	 * @param string $item
50
	 *
51
	 * @return False_class
1 ignored issue
show
Documentation introduced by
Should the return type not be boolean?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
52
	 */
53
	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 8
	function __call ($method, $params) {
65 8
		return $this;
66
	}
67
	/**
68
	 * Calling as callable
69
	 *
70
	 * @return False_class
71
	 */
72
	function __invoke () {
73
		return $this;
74
	}
75
	/**
76
	 * @return string
77
	 */
78
	function __toString () {
79
		return '0';
80
	}
81
	/**
82
	 * If item exists
83
	 */
84
	function offsetExists ($offset) {
85
		return false;
86
	}
87
	/**
88
	 * Get item
89
	 */
90
	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