JmsSerializer   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 37
c 0
b 0
f 0
wmc 3
lcom 1
cbo 2
ccs 7
cts 7
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 2
A serialize() 0 4 1
1
<?php
2
3
namespace TreeHouse\Queue\Message\Serializer;
4
5
use JMS\Serializer\SerializationContext;
6
use JMS\Serializer\SerializerInterface as BaseSerializer;
7
8
class JmsSerializer implements SerializerInterface
9
{
10
    /**
11
     * @var BaseSerializer
12
     */
13
    protected $serializer;
14
15
    /**
16
     * @var SerializationContext
17
     */
18
    protected $context;
19
20
    /**
21
     * @var string
22
     */
23
    protected $format;
24
25
    /**
26
     * @param BaseSerializer       $serializer
27
     * @param string               $format
28
     * @param SerializationContext $context
29
     */
30 3
    public function __construct(BaseSerializer $serializer, $format = 'json', SerializationContext $context = null)
31
    {
32 3
        $this->serializer = $serializer;
33 3
        $this->format = $format;
34 3
        $this->context = $context ?: SerializationContext::create();
35 3
    }
36
37
    /**
38
     * @inheritdoc
39
     */
40 2
    public function serialize($value)
41
    {
42 2
        return $this->serializer->serialize($value, $this->format, $this->context);
43
    }
44
}
45