TransformerRegistry::offsetUnset()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
3
namespace Alchemy\Rest\Response;
4
5
use League\Fractal\TransformerAbstract;
6
7
class TransformerRegistry implements \ArrayAccess
8
{
9
10
    private $transformers = array();
11
12
    /**
13
     * @param string $key
14
     * @param TransformerAbstract $transformer
15
     */
16 12
    public function setTransformer($key, TransformerAbstract $transformer)
17
    {
18 12
        $this->transformers[$key] = $transformer;
19 12
    }
20
21 20
    public function offsetExists($offset)
22
    {
23 20
        return isset($this->transformers[$offset]);
24
    }
25
26 14
    public function offsetGet($offset)
27
    {
28 14
        return $this->transformers[$offset];
29
    }
30
31 6
    public function offsetSet($offset, $value)
32
    {
33 6
        if (! $value instanceof TransformerAbstract) {
34 2
            throw new \InvalidArgumentException('Value must be an instance of League\Fractal\AbstractTransformer');
35
        }
36
37 4
        $this->transformers[$offset] = $value;
38 4
    }
39
40 2
    public function offsetUnset($offset)
41
    {
42 2
        unset($this->transformers[$offset]);
43 2
    }
44
}
45