TransformerRegistry::getEncodingTransformer()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
/*
4
 * This file is part of the XabbuhPandaClient package.
5
 *
6
 * (c) Christian Flothmann <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Xabbuh\PandaClient\Transformer;
13
14
/**
15
 * Registry for the model transformers.
16
 *
17
 * @author Christian Flothmann <[email protected]>
18
 */
19
class TransformerRegistry implements TransformerRegistryInterface
20
{
21
    /**
22
     * The generated transformers
23
     *
24
     * @var array
25
     */
26
    private $transformers = array();
27
28 9
    private function set($class, $transformer)
29
    {
30 9
        $this->transformers[$class] = $transformer;
31 9
    }
32
33 6
    private function get($class)
34
    {
35 6
        if (!isset($this->transformers[$class])) {
36 5
            throw new \InvalidArgumentException(
37 5
                'No transformer configured for model '.$class
38
            );
39
        }
40
41 1
        return $this->transformers[$class];
42
    }
43
44
    /**
45
     * {@inheritDoc}
46
     */
47 9
    public function setCloudTransformer(CloudTransformerInterface $transformer)
48
    {
49 9
        $this->set('Cloud', $transformer);
50 9
    }
51
52
    /**
53
     * {@inheritDoc}
54
     */
55 2
    public function getCloudTransformer()
56
    {
57 2
        return $this->get('Cloud');
58
    }
59
60
    /**
61
     * {@inheritDoc}
62
     */
63 9
    public function setEncodingTransformer(EncodingTransformerInterface $transformer)
64
    {
65 9
        $this->set('Encoding', $transformer);
66 9
    }
67
68
    /**
69
     * {@inheritDoc}
70
     */
71 2
    public function getEncodingTransformer()
72
    {
73 2
        return $this->get('Encoding');
74
    }
75
76
    /**
77
     * {@inheritDoc}
78
     */
79 9
    public function setNotificationsTransformer(NotificationsTransformerInterface $transformer)
80
    {
81 9
        $this->set('Notifications', $transformer);
82 9
    }
83
84
    /**
85
     * {@inheritDoc}
86
     */
87 2
    public function getNotificationsTransformer()
88
    {
89 2
        return $this->get('Notifications');
90
    }
91
92
    /**
93
     * {@inheritDoc}
94
     */
95 9
    public function setProfileTransformer(ProfileTransformerInterface $transformer)
96
    {
97 9
        $this->set('Profile', $transformer);
98 9
    }
99
100
    /**
101
     * {@inheritDoc}
102
     */
103 2
    public function getProfileTransformer()
104
    {
105 2
        return $this->get('Profile');
106
    }
107
108
    /**
109
     * {@inheritDoc}
110
     */
111 9
    public function setVideoTransformer(VideoTransformerInterface $transformer)
112
    {
113 9
        $this->set('Video', $transformer);
114 9
    }
115
116
    /**
117
     * {@inheritDoc}
118
     */
119 2
    public function getVideoTransformer()
120
    {
121 2
        return $this->get('Video');
122
    }
123
}
124