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

SerializerCommandExtractor::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 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