Passed
Push — feature/unit-tests ( 785607...45ce75 )
by Daniel
05:06
created

AbstractAction::getFormat()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
/*
4
 * This file is part of the Silverback API Component Bundle Project
5
 *
6
 * (c) Daniel West <[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
declare(strict_types=1);
13
14
namespace Silverback\ApiComponentBundle\Action;
15
16
use Silverback\ApiComponentBundle\Exception\InvalidParameterException;
17
use Silverback\ApiComponentBundle\Factory\ResponseFactory;
18
use Silverback\ApiComponentBundle\Serializer\SerializeFormatResolver;
19
use Symfony\Component\Serializer\Encoder\DecoderInterface;
20
use Symfony\Component\Serializer\SerializerInterface;
21
22
/**
23
 * @author Daniel West <[email protected]>
24
 */
25
class AbstractAction
26
{
27
    /**
28
     * @var DecoderInterface|SerializerInterface
29
     */
30
    protected SerializerInterface $serializer;
31
    protected SerializeFormatResolver $requestFormatResolver;
32
    protected ResponseFactory $responseFactory;
33
34
    public function __construct(SerializerInterface $serializer, SerializeFormatResolver $requestFormatResolver, ResponseFactory $responseFactory)
35
    {
36
        if (!$serializer instanceof DecoderInterface) {
37
            throw new InvalidParameterException(sprintf('The serializer injected into %s should implement %s', __CLASS__, DecoderInterface::class));
38
        }
39
        $this->serializer = $serializer;
40
        $this->requestFormatResolver = $requestFormatResolver;
41
        $this->responseFactory = $responseFactory;
42
    }
43
}
44