ViolationNormalizer::normalize()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
crap 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Paysera\Bundle\ApiBundle\Normalizer;
5
6
use Paysera\Bundle\ApiBundle\Entity\Violation;
7
use Paysera\Component\Normalization\NormalizationContext;
8
use Paysera\Component\Normalization\NormalizerInterface;
9
use Paysera\Component\Normalization\TypeAwareInterface;
10
11
class ViolationNormalizer implements NormalizerInterface, TypeAwareInterface
12
{
13
    /**
14
     * @param Violation $result
15
     * @param NormalizationContext $normalizationContext
16
     * @return array
17
     */
18 12
    public function normalize($result, NormalizationContext $normalizationContext)
19
    {
20
        return [
21 12
            'code' => $result->getCode(),
22 12
            'message' => $result->getMessage(),
23 12
            'field' => $result->getField(),
24
        ];
25
    }
26
27 96
    public function getType(): string
28
    {
29 96
        return Violation::class;
30
    }
31
}
32