Entity::offsetUnset()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
/**
3
 * Created by Maciej Paprocki for Bureau-VA.
4
 * Date: 17/02/2016
5
 * Project Name: MaciekPaprocki\WordpressGuzzle
6
 * Time: 11:27.
7
 */
8
namespace BureauVa\WordpressGuzzle\Entity;
9
10
/**
11
 * Class Entity.
12
 */
13
abstract class Entity implements \ArrayAccess
14
{
15
    protected $internaleCounter = 0;
16
17
    /**
18
     * @param $offset
19
     * @param $value
20
     */
21 2
    public function offsetSet($offset, $value)
22
    {
23 2
        if (is_null($offset)) {
24 2
            $this->{$this->internaleCounter} = $value;
25 2
            ++$this->internaleCounter;
26 1
        } else {
27 2
            $this->{$offset} = $value;
28
        }
29 2
    }
30
31
    /**
32
     * @param $offset
33
     *
34
     * @return bool
35
     */
36 2
    public function offsetExists($offset)
37
    {
38 2
        return isset($this->{$offset});
39
    }
40
41
    /**
42
     * @param $offset
43
     */
44 2
    public function offsetUnset($offset)
45
    {
46 2
        unset($this->{$offset});
47 2
    }
48
49
    /**
50
     * @param $offset
51
     */
52 2
    public function offsetGet($offset)
53
    {
54 2
        return isset($this->{$offset}) ? $this->{$offset} : null;
55
    }
56
}
57