AbstractChain::jsonSerialize()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
3
namespace Cocur\Chain;
4
5
use ArrayAccess;
6
use ArrayIterator;
7
use IteratorAggregate;
8
use JsonSerializable;
9
10
/**
11
 * Chain.
12
 *
13
 * @author    Florian Eckerstorfer
14
 * @copyright 2015-2018 Florian Eckerstorfer
15
 */
16
abstract class AbstractChain implements ArrayAccess, IteratorAggregate, JsonSerializable
17
{
18
    /**
19
     * @var array
20
     */
21
    public $array = [];
22
23
    /**
24
     * @return ArrayIterator
25
     */
26 1
    public function getIterator(): ArrayIterator
27
    {
28 1
        return new ArrayIterator($this->array);
29
    }
30
31
    /**
32
     * @param mixed $offset
33
     *
34
     * @return bool
35
     */
36 1
    public function offsetExists($offset): bool
37
    {
38 1
        return isset($this->array[$offset]);
39
    }
40
41
    /**
42
     * @param mixed $offset
43
     *
44
     * @return mixed
45
     */
46 1
    public function offsetGet($offset)
47
    {
48 1
        return $this->array[$offset];
49
    }
50
51
    /**
52
     * @param mixed $offset
53
     * @param mixed $value
54
     */
55 1
    public function offsetSet($offset, $value): void
56
    {
57 1
        $this->array[$offset] = $value;
58 1
    }
59
60
    /**
61
     * @param mixed $offset
62
     */
63 1
    public function offsetUnset($offset): void
64
    {
65 1
        unset($this->array[$offset]);
66 1
    }
67
68
    /**
69
     * @return array
70
     */
71 1
    public function jsonSerialize(): array
72
    {
73 1
        return $this->array;
74
    }
75
}
76