Failed Conditions
Pull Request — master (#10)
by Yo
02:50
created

ComposerEncoder::supportsEncoding()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

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
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
namespace Yoanm\ComposerConfigManager\Infrastructure\Serializer\Encoder;
3
4
use Symfony\Component\Serializer\Encoder\DecoderInterface;
5
use Symfony\Component\Serializer\Encoder\EncoderInterface;
6
use Symfony\Component\Serializer\Exception\UnexpectedValueException;
7
use Yoanm\ComposerConfigManager\Application\Serializer\Encoder\ComposerEncoder as AppComposerEncoder;
8
9
class ComposerEncoder implements EncoderInterface, DecoderInterface
10
{
11
    const FORMAT = 'composer';
12
13
    /** @var AppComposerEncoder */
14
    private $appComposerEncoder;
15
16 3
    public function __construct(AppComposerEncoder $appComposerEncoder)
17
    {
18 3
        $this->appComposerEncoder = $appComposerEncoder;
19 3
    }
20
21
    /**
22
     * {@inheritdoc}
23
     */
24 1
    public function encode($data, $format, array $context = array())
25
    {
26 1
        return $this->appComposerEncoder->encode($data);
27
    }
28
29
    /**
30
     * {@inheritdoc}
31
     */
32 2
    public function supportsEncoding($format)
33
    {
34 2
        return $this->isSupportedFormat($format);
35
    }
36
37
    /**
38
     * {@inheritdoc}
39
     */
40
    public function decode($data, $format, array $context = array())
41
    {
42
        return $this->appComposerEncoder->decode($data);
43
    }
44
45
    /**
46
     * {@inheritdoc}
47
     */
48
    public function supportsDecoding($format)
49
    {
50
        return $this->isSupportedFormat($format);
51
    }
52
53
    /**
54
     * {@inheritdoc}
55
     */
56 2
    public function isSupportedFormat($format)
57
    {
58 2
        return self::FORMAT === $format;
59
    }
60
}
61