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

CreateShipmentResponseFactory   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 17
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 11 1
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