Passed
Pull Request — master (#2)
by Dominik
02:25
created

getNormalizationFieldMappings()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10

Duplication

Lines 10
Ratio 100 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 0
Metric Value
dl 10
loc 10
ccs 6
cts 6
cp 1
rs 9.9332
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Chubbyphp\ApiHttp\Serialization\ApiProblem\ClientError;
6
7
use Chubbyphp\ApiHttp\ApiProblem\ClientError\PaymentRequired;
8
use Chubbyphp\ApiHttp\Serialization\ApiProblem\AbstractApiProblemMapping;
9
use Chubbyphp\Serialization\Accessor\MethodAccessor;
10
use Chubbyphp\Serialization\Mapping\NormalizationFieldMappingBuilder;
11
use Chubbyphp\Serialization\Mapping\NormalizationFieldMappingInterface;
12
use Chubbyphp\Serialization\Normalizer\FieldNormalizer;
13
14 View Code Duplication
final class PaymentRequiredMapping extends AbstractApiProblemMapping
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
15
{
16
    /**
17
     * @return string
18
     */
19 1
    public function getClass(): string
20
    {
21 1
        return PaymentRequired::class;
22
    }
23
24
    /**
25
     * @param string $path
26
     *
27
     * @return NormalizationFieldMappingInterface[]
28
     */
29 1
    public function getNormalizationFieldMappings(string $path): array
30
    {
31 1
        $fieldMappings = parent::getNormalizationFieldMappings($path);
32
33 1
        $fieldMappings[] = NormalizationFieldMappingBuilder::create('paymentTypes')
34 1
            ->setFieldNormalizer(new FieldNormalizer(new MethodAccessor('paymentTypes')))
35 1
            ->getMapping();
36
37 1
        return $fieldMappings;
38
    }
39
}
40