ErrorNormalizer   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 0
loc 24
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A normalize() 0 11 2
A getType() 0 4 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Maba\Bundle\RestBundle\Normalizer;
5
6
use Maba\Bundle\RestBundle\Entity\Error;
7
use Paysera\Component\Normalization\NormalizationContext;
8
use Paysera\Component\Normalization\NormalizerInterface;
9
use Paysera\Component\Normalization\TypeAwareInterface;
10
11
class ErrorNormalizer implements NormalizerInterface, TypeAwareInterface
12
{
13
    /**
14
     * @param Error $result
15
     * @param NormalizationContext $normalizationContext
16
     * @return array
17
     */
18 33
    public function normalize($result, NormalizationContext $normalizationContext)
19
    {
20
        return [
21 33
            'error' => $result->getCode(),
22 33
            'error_description' => $result->getMessage(),
23 33
            'error_uri' => $result->getUri(),
24 33
            'error_properties' => $result->getProperties(),
25 33
            'error_data' => $result->getData(),
26 33
            'errors' => $result->getViolations() !== [] ? $result->getViolations() : null,
27
        ];
28
    }
29
30 81
    public function getType(): string
31
    {
32 81
        return Error::class;
33
    }
34
}
35