Completed
Push — master ( ed7e26...883d13 )
by Maciej
12:17
created

Entity   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 7
c 2
b 0
f 1
lcom 1
cbo 1
dl 0
loc 56
rs 10

5 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
A setSecure() 0 6 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
9
namespace BureauVa\WordpressGuzzle\Entity;
10
11
use BureauVa\WordpressGuzzle\Helper\StringHelper;
12
13
/**
14
 * Class Entity
15
 * @package MaciekPaprocki\WordpressGuzzle
16
 */
17
18
abstract class Entity implements \ArrayAccess
19
{
20
    protected $internaleCounter = 0;
21
22
    /**
23
     * @param $offset
24
     * @param $value
25
     */
26
    public function offsetSet($offset, $value)
27
    {
28
        if (is_null($offset)) {
29
            $this->{$this->internaleCounter} = $value;
30
            $this->internaleCounter++;
31
        } else {
32
            $this->{$offset} = $value;
33
        }
34
    }
35
36
    /**
37
     * @param $offset
38
     * @return bool
39
     */
40
    public function offsetExists($offset)
41
    {
42
        return isset($this->{$offset});
43
    }
44
45
    /**
46
     * @param $offset
47
     */
48
    public function offsetUnset($offset)
49
    {
50
        unset($this->{$offset});
51
    }
52
53
    /**
54
     * @param $offset
55
     * @return null
56
     */
57
    public function offsetGet($offset)
58
    {
59
        return isset($this->{$offset}) ? $this->{$offset} : null;
60
    }
61
62
    /**
63
     * @param $name
64
     * @param $val
65
     * @return $this
66
     */
67
    public function setSecure($name, $val)
68
    {
69
        $name = StringHelper::noFirstCamelCase($name);
70
        $this->{$name} = $val;
71
        return $this;
72
    }
73
}
74