SwaggerDecorator::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the zibios/sharep.
7
 *
8
 * (c) Zbigniew Ślązak
9
 */
10
11
namespace App\Swagger\Decorator;
12
13
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
14
15
final class SwaggerDecorator implements NormalizerInterface
16
{
17
    private $decorated;
18
19 27
    public function __construct(NormalizerInterface $decorated)
20
    {
21 27
        $this->decorated = $decorated;
22 27
    }
23
24
    /**
25
     * @param mixed  $object Object to normalize
26
     * @param string $format Format the normalization result will be encoded as
0 ignored issues
show
Documentation introduced by
Should the type for parameter $format not be string|null?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
27
     *
28
     * @return array|string|int|float|bool
29
     */
30 1
    public function normalize($object, $format = null, array $context = [])
31
    {
32
        /** @var array $docs */
33 1
        $docs = $this->decorated->normalize($object, $format, $context);
34 1
        if (\is_array($docs)) {
35 1
            $docs['info']['title'] = 'Shared Resources API';
36
        }
37
38 1
        return $docs;
39
    }
40
41
    /**
42
     * {@inheritdoc}
43
     */
44 18
    public function supportsNormalization($data, $format = null): bool
45
    {
46 18
        return $this->decorated->supportsNormalization($data, $format);
47
    }
48
}
49