Total Complexity | 5 |
Total Lines | 29 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
9 | class Compact extends \ArrayIterator implements \JsonSerializable |
||
10 | { |
||
11 | // private static $value; |
||
12 | // public function __construct($argument) |
||
13 | // { |
||
14 | // self::$value = $argument; |
||
15 | // // if ($argument instanceof \Countable && count($argument) > 0) { |
||
16 | // // # it's an array-like |
||
17 | // // } else { |
||
18 | // // //it's an object-like |
||
19 | // // } |
||
20 | // } |
||
21 | // |
||
22 | public function __construct() |
||
1 ignored issue
–
show
|
|||
23 | { |
||
24 | parent::__construct([], 1);//1 = Array indices can be accessed as properties in read/write. |
||
25 | } |
||
26 | |||
27 | public function jsonSerialize() |
||
28 | { |
||
29 | $prop = get_object_vars($this); |
||
30 | if (count($prop) > 0) return $prop; |
||
1 ignored issue
–
show
|
|||
31 | if (count($this) > 0) return iterator_to_array($this); |
||
1 ignored issue
–
show
|
|||
32 | } |
||
33 | |||
34 | public static function wrap($arrayOrObject) |
||
38 | } |
||
39 | } |
||
40 |