BodyContentType   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 1
dl 0
loc 48
ccs 15
cts 15
cp 1
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A setSupportedContentTypes() 0 5 1
A setJsonEncodedBody() 0 5 1
A isSeveralSupported() 0 4 1
A apply() 0 4 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Paysera\Bundle\ApiBundle\Annotation;
5
6
use Paysera\Bundle\ApiBundle\Entity\RestRequestOptions;
7
use Paysera\Bundle\ApiBundle\Service\Annotation\ReflectionMethodWrapper;
8
9
/**
10
 * @Annotation
11
 * @Target({"METHOD"})
12
 */
13
class BodyContentType implements RestAnnotationInterface
14
{
15
    /**
16
     * @var array
17
     */
18
    private $supportedContentTypes;
19
20
    /**
21
     * @var bool
22
     */
23
    private $jsonEncodedBody;
24
25 96
    public function __construct(array $options)
26
    {
27 96
        $this->setSupportedContentTypes($options['supportedContentTypes']);
28 96
        $this->setJsonEncodedBody($options['jsonEncodedBody'] ?? false);
29 96
    }
30
31
    /**
32
     * @param array $supportedContentTypes
33
     * @return $this
34
     */
35 96
    private function setSupportedContentTypes(array $supportedContentTypes): self
36
    {
37 96
        $this->supportedContentTypes = $supportedContentTypes;
38 96
        return $this;
39
    }
40
41
    /**
42
     * @param bool $jsonEncodedBody
43
     * @return $this
44
     */
45 96
    private function setJsonEncodedBody(bool $jsonEncodedBody): self
46
    {
47 96
        $this->jsonEncodedBody = $jsonEncodedBody;
48 96
        return $this;
49
    }
50
51 96
    public function isSeveralSupported(): bool
52
    {
53 96
        return false;
54
    }
55
56 96
    public function apply(RestRequestOptions $options, ReflectionMethodWrapper $reflectionMethod)
57
    {
58 96
        $options->setSupportedContentTypes($this->supportedContentTypes, $this->jsonEncodedBody);
59 96
    }
60
}
61