TransformerRegistry   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
c 1
b 0
f 0
lcom 1
cbo 0
dl 0
loc 38
ccs 15
cts 15
cp 1
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A setTransformer() 0 4 1
A offsetExists() 0 4 1
A offsetGet() 0 4 1
A offsetSet() 0 8 2
A offsetUnset() 0 4 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