Passed
Push — develop ( c6da07...04f323 )
by Alexey
13:11 queued 11s
created

ItemNormalizer   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
dl 0
loc 16
ccs 6
cts 6
cp 1
rs 10
c 1
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A normalize() 0 4 1
A hasCacheableSupportsMethod() 0 3 1
A supportsNormalization() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * Copyright (c) 2022 Ne-Lexa <[email protected]>
7
 *
8
 * For the full copyright and license information, please view
9
 * the LICENSE file that was distributed with this source code.
10
 *
11
 * @see https://github.com/Ne-Lexa/roach-php-bundle
12
 */
13
14
namespace Nelexa\RoachPhpBundle\Normalizer;
15
16
use RoachPHP\ItemPipeline\ItemInterface;
17
use Symfony\Component\Serializer\Normalizer\CacheableSupportsMethodInterface;
18
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
19
20
class ItemNormalizer implements NormalizerInterface, CacheableSupportsMethodInterface
21
{
22 1
    public function hasCacheableSupportsMethod(): bool
23
    {
24 1
        return true;
25
    }
26
27 1
    public function supportsNormalization(mixed $data, ?string $format = null): bool
28
    {
29 1
        return $data instanceof ItemInterface;
30
    }
31
32 1
    public function normalize(mixed $object, ?string $format = null, array $context = []): array
33
    {
34
        /** @psalm-suppress all */
35 1
        return $object->all();
36
    }
37
}
38