Completed
Push — master ( 0864bb...f3fc5f )
by Fede
08:54 queued 07:04
created

Environment::offsetSet()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2.032

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 4
cts 5
cp 0.8
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 5
nc 2
nop 2
crap 2.032
1
<?php
2
3
namespace LisPhp\Environment;
4
5
abstract class Environment implements IEnvironment
6
{
7
    /**
8
     * @var array
9
     */
10
    protected $container = [];
11
12 9
    public function offsetSet($offset, $value)
13
    {
14 9
        if (is_null($offset)) {
15
            $this->container[] = $value;
16
        } else {
17 9
            $this->container[$offset] = $value;
18
        }
19 9
    }
20
21 9
    public function offsetExists($offset)
22
    {
23 9
        return isset($this->container[$offset]);
24
    }
25
26
    public function offsetUnset($offset)
27
    {
28
        unset($this->container[$offset]);
29
    }
30
31 21
    public function offsetGet($offset)
32
    {
33 21
        return isset($this->container[$offset]) ? $this->container[$offset] : null;
34
    }
35
}
36