Passed
Pull Request — master (#57)
by Daniel
16:36 queued 11:06
created

AbstractAction   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 17
ccs 0
cts 6
cp 0
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 2
1
<?php
2
3
/*
4
 * This file is part of the Silverback API Components 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\ApiComponentsBundle\Action;
15
16
use Silverback\ApiComponentsBundle\Exception\InvalidArgumentException;
17
use Silverback\ApiComponentsBundle\Factory\Response\ResponseFactory;
18
use Silverback\ApiComponentsBundle\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 InvalidArgumentException(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