Passed
Pull Request — main (#92)
by Niels
02:43
created

ProblemExceptionNormalizer::supportsNormalization()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 3
c 1
b 0
f 0
nc 2
nop 3
dl 0
loc 7
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the OpenapiBundle package.
7
 *
8
 * (c) Niels Nijens <[email protected]>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Nijens\OpenapiBundle\ExceptionHandling\Normalizer;
15
16
use Nijens\OpenapiBundle\ExceptionHandling\Exception\ProblemExceptionInterface;
17
use Nijens\OpenapiBundle\NijensOpenapiBundle;
18
use Symfony\Component\Serializer\Normalizer\NormalizerAwareInterface;
19
use Throwable;
20
21
/**
22
 * Normalizes a {@see Throwable} implementing the {@see ProblemExceptionInterface}.
23
 *
24
 * @author Niels Nijens <[email protected]>
25
 */
26
if (NijensOpenapiBundle::getSymfonyVersion() < 70000) {
27
    final class ProblemExceptionNormalizer extends AbstractProblemExceptionNormalizer implements NormalizerInterface, NormalizerAwareInterface
28
    {
29
        /**
30
         * @return array
31
         */
32
        public function normalize($object, $format = null, array $context = []): float|int|bool|\ArrayObject|array|string|null
33
        {
34
            return $this->doNormalize($object, $format, $context);
35
        }
36
    }
37
} else {
38
    final class ProblemExceptionNormalizer extends AbstractProblemExceptionNormalizer implements NormalizerInterface, NormalizerAwareInterface
39
    {
40
        public function normalize($object, $format = null, array $context = []): array
41
        {
42
            return $this->doNormalize($object, $format, $context);
43
        }
44
    }
45
}
46