Passed
Branch master (98e19a)
by Petrică
02:49 queued 10s
created

ValuesCollection   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 90
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 9
c 1
b 0
f 0
lcom 1
cbo 0
dl 0
loc 90
ccs 22
cts 22
cp 1
rs 10

9 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A add() 0 6 1
A getValues() 0 4 1
A getIterator() 0 4 1
A offsetExists() 0 4 1
A offsetGet() 0 4 1
A offsetSet() 0 4 1
A offsetUnset() 0 4 1
A count() 0 4 1
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: Petrica
5
 * Date: 3/29/2016
6
 * Time: 1:49
7
 */
8
namespace Petrica\StatsdSystem\Collection;
9
10
use Countable, IteratorAggregate, ArrayAccess;
11
12
class ValuesCollection implements Countable, IteratorAggregate, ArrayAccess
13
{
14
    /**
15
     * @var array
16
     */
17
    private $values;
18
19
    /**
20
     * ValuesCollection constructor
21
     *
22
     * @param $values array
23
     */
24 3
    public function __construct(array $values = array())
25
    {
26 3
        $this->values = $values;
27 3
    }
28
29
    /**
30
     * Add a value to collection
31
     *
32
     * @param $key
33
     * @param $value
34
     *
35
     * @return $this
36
     */
37 3
    public function add($key, $value)
38
    {
39 3
        $this->values[$key] = $value;
40
41 3
        return $this;
42
    }
43
44
    /**
45
     * Return stored values
46
     *
47
     * @return array
48
     */
49 3
    public function getValues()
50
    {
51 3
        return $this->values;
52
    }
53
54
    /**
55
     * {@inheritdoc}
56
     */
57 1
    public function getIterator()
58
    {
59 1
        return new \ArrayIterator($this->values);
60
    }
61
62
    /**
63
     * {@inheritdoc}
64
     */
65 1
    public function offsetExists($offset)
66
    {
67 1
        return isset($this->values[$offset]);
68
    }
69
70
    /**
71
     * {@inheritdoc}
72
     */
73 1
    public function offsetGet($offset)
74
    {
75 1
        return $this->values[$offset];
76
    }
77
78
    /**
79
     * {@inheritdoc}
80
     */
81 1
    public function offsetSet($offset, $value)
82
    {
83 1
        $this->values[$offset] = $value;
84 1
    }
85
86
    /**
87
     * {@inheritdoc}
88
     */
89 1
    public function offsetUnset($offset)
90
    {
91 1
        unset($this->values[$offset]);
92 1
    }
93
94
    /**
95
     * {@inheritdoc}
96
     */
97 1
    public function count()
98
    {
99 1
        return count($this->values);
100
    }
101
}