Passed
Push — master ( 03f4ad...0a78e0 )
by Stefano
01:49
created

HasDataTrait   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 10
lcom 1
cbo 0
dl 0
loc 50
ccs 0
cts 36
cp 0
rs 10
c 0
b 0
f 0

9 Methods

Rating   Name   Duplication   Size   Complexity  
A __toString() 0 4 1
A __debugInfo() 0 4 1
A offsetExists() 0 4 1
A offsetGet() 0 4 2
A offsetSet() 0 4 1
A offsetUnset() 0 4 1
A count() 0 4 1
A getIterator() 0 4 1
A toArray() 0 4 1
1
<?php
2
3
namespace GuzzleHttp\Command;
4
5
/**
6
 * Basic collection behavior for Command and Result objects.
7
 *
8
 * The methods in the class are primarily for implementing the ArrayAccess,
9
 * Countable, and IteratorAggregate interfaces.
10
 */
11
trait HasDataTrait
12
{
13
    /** @var array Data stored in the collection. */
14
    protected $data;
15
16
    public function __toString()
17
    {
18
        return print_r($this, true);
19
    }
20
21
    public function __debugInfo()
22
    {
23
        return $this->data;
24
    }
25
26
    public function offsetExists($offset)
27
    {
28
        return array_key_exists($offset, $this->data);
29
    }
30
31
    public function offsetGet($offset)
32
    {
33
        return isset($this->data[$offset]) ? $this->data[$offset] : null;
34
    }
35
36
    public function offsetSet($offset, $value)
37
    {
38
        $this->data[$offset] = $value;
39
    }
40
41
    public function offsetUnset($offset)
42
    {
43
        unset($this->data[$offset]);
44
    }
45
46
    public function count()
47
    {
48
        return count($this->data);
49
    }
50
51
    public function getIterator()
52
    {
53
        return new \ArrayIterator($this->data);
54
    }
55
56
    public function toArray()
57
    {
58
        return $this->data;
59
    }
60
}
61