Entity   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 3
Bugs 0 Features 1
Metric Value
wmc 6
c 3
b 0
f 1
lcom 1
cbo 0
dl 0
loc 44
ccs 14
cts 14
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A offsetSet() 0 9 2
A offsetExists() 0 4 1
A offsetUnset() 0 4 1
A offsetGet() 0 4 2
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