Completed
Push — master ( 99fd04...6a3a72 )
by Jakub
02:38
created

SerializerCommandExtractor   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 2
dl 0
loc 21
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A extractFromRequest() 0 4 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Eps\Req2CmdBundle\CommandExtractor;
5
6
use Symfony\Component\HttpFoundation\Request;
7
use Symfony\Component\Serializer\SerializerInterface;
8
9
class SerializerCommandExtractor implements CommandExtractorInterface
10
{
11
    /**
12
     * @var SerializerInterface
13
     */
14
    private $serializer;
15
16
    public function __construct(SerializerInterface $serializer)
17
    {
18
        $this->serializer = $serializer;
19
    }
20
21
    /**
22
     * {@inheritdoc}
23
     * @throws \LogicException
24
     */
25
    public function extractFromRequest(Request $request, string $cmdClassName)
26
    {
27
        return $this->serializer->deserialize($request->getContent(), $cmdClassName, $request->getRequestFormat());
28
    }
29
}
30