ArrayAccess   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 5
Bugs 4 Features 0
Metric Value
wmc 5
c 5
b 4
f 0
lcom 1
cbo 0
dl 0
loc 53
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A offsetExists() 0 4 1
A offsetGet() 0 4 2
A offsetUnset() 0 4 1
A offsetSet() 0 4 1
1
<?php
2
3
namespace PEIP\Data;
4
5
/*
6
 * This file is part of the PEIP package.
7
 * (c) 2009-2011 Timo Michna <timomichna/yahoo.de>
8
 *
9
 * For the full copyright and license information, please view the LICENSE
10
 * file that was distributed with this source code.
11
 */
12
13
/**
14
 * ArrayAccess
15
 * Simple implementation of the PHP�s native ArrayAccess interface.
16
 *
17
 * @author Timo Michna <timomichna/yahoo.de>
18
 * @implements ArrayAccess
19
 */
20
class ArrayAccess implements \ArrayAccess
21
{
22
    protected $values = [];
23
24
    /**
25
     * Checks wether a given offset exists.
26
     *
27
     * @param mixed $offset the offset
28
     *
29
     * @return
30
     */
31
    public function offsetExists($offset)
32
    {
33
        return array_key_exists($name, $this->values);
0 ignored issues
show
Bug introduced by
The variable $name does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
34
    }
35
36
    /**
37
     * returns the value for agiven offset.
38
     *
39
     * @param mixed $offset the offset
40
     *
41
     * @return
42
     */
43
    public function offsetGet($offset)
44
    {
45
        return array_key_exists($name, $this->values) ? $this->values[$offset] : null;
0 ignored issues
show
Bug introduced by
The variable $name does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
46
    }
47
48
    /**
49
     * Deletes the a given offset.
50
     *
51
     * @param mixed $offset the offset
52
     *
53
     * @return
54
     */
55
    public function offsetUnset($offset)
56
    {
57
        unset($this->values[$offset]);
58
    }
59
60
    /**
61
     * Sets the value for a given offset.
62
     *
63
     * @param mixed $offset the offset
64
     * @param mixed $value  value for the offset
65
     *
66
     * @return
67
     */
68
    public function offsetSet($offset, $value)
69
    {
70
        $this->values[$offset] = $value;
71
    }
72
}
73