Issues (15)

src/Serializer/LessonNormalizer.php (1 issue)

Labels
Severity
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Serializer;
6
7
use App\Model\LessonInterface;
8
use App\Serializer\Processor\FileHrefProcessor;
9
use App\Serializer\Processor\LessonCompletedProcessor;
10
use App\Serializer\Processor\LessonPaginationProcessor;
11
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
12
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
13
14
class LessonNormalizer implements NormalizerInterface
15
{
16
    private $normalizer;
17
    private $fileHrefProcessor;
18
    private $lessonCompletedProcessor;
19
    private $lessonPaginationProcessor;
20
21
    public function __construct(
22
        ObjectNormalizer $normalizer,
23
        FileHrefProcessor $fileHrefProcessor,
24
        LessonCompletedProcessor $lessonCompletedProcessor,
25
        LessonPaginationProcessor $lessonPaginationProcessor
26
    ) {
27
        $this->normalizer = $normalizer;
28
        $this->fileHrefProcessor = $fileHrefProcessor;
29
        $this->lessonCompletedProcessor = $lessonCompletedProcessor;
30
        $this->lessonPaginationProcessor = $lessonPaginationProcessor;
31
    }
32
33
    public function normalize($object, $format = null, array $context = [])
34
    {
35
        $data = $this->normalizer->normalize($object, $format, $context);
36
        $data = $this->fileHrefProcessor->process($object, $data);
0 ignored issues
show
It seems like $data can also be of type ArrayObject; however, parameter $data of App\Serializer\Processor...refProcessor::process() does only seem to accept array, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

36
        $data = $this->fileHrefProcessor->process($object, /** @scrutinizer ignore-type */ $data);
Loading history...
37
        $data = $this->lessonCompletedProcessor->process($object, $data);
38
        $data = $this->lessonPaginationProcessor->process($object, $data);
39
40
        return $data;
41
    }
42
43
    public function supportsNormalization($data, $format = null): bool
44
    {
45
        return $data instanceof LessonInterface;
46
    }
47
}
48