Passed
Push — main ( 7189b9...23cbe4 )
by Vasil
03:17
created

CreateShipmentResponseFactory::__invoke()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 6
nc 1
nop 1
dl 0
loc 11
ccs 9
cts 9
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace VasilDakov\Speedy\Service\Shipment;
6
7
use JMS\Serializer;
8
9
/**
10
 * Class CreateShipmentResponseFactory
11
 *
12
 * @author Vasil Dakov <[email protected]>
13
 * @copyright 2009-2022 Neutrino.bg
14
 * @version 1.0
15
 */
16
class CreateShipmentResponseFactory
17
{
18
    /**
19
     * @param string $json
20
     * @return CreateShipmentResponse
21
     */
22 2
    public function __invoke(string $json): CreateShipmentResponse
23
    {
24 2
        $serializer = Serializer\SerializerBuilder::create()
25 2
            ->setPropertyNamingStrategy(
26 2
                new Serializer\Naming\SerializedNameAnnotationStrategy(
27 2
                    new Serializer\Naming\IdenticalPropertyNamingStrategy()
28 2
                )
29 2
            )
30 2
            ->build();
31
32 2
        return $serializer->deserialize($json, CreateShipmentResponse::class, 'json');
33
    }
34
}
35