Passed
Pull Request — develop (#155)
by Laurent
02:14
created

SupplierHandler   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 29
dl 0
loc 46
rs 10
c 2
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getSubscribingMethods() 0 14 1
A serialize() 0 26 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the G.L.S.R. Apps package.
7
 *
8
 * (c) Dev-Int Création <[email protected]>.
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Administration\Infrastructure\Supplier\Serializer\Handler;
15
16
use Administration\Application\Supplier\ReadModel\Supplier as SupplierReadModel;
17
use JMS\Serializer\GraphNavigator;
0 ignored issues
show
Bug introduced by
The type JMS\Serializer\GraphNavigator was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
18
use JMS\Serializer\Handler\SubscribingHandlerInterface;
0 ignored issues
show
Bug introduced by
The type JMS\Serializer\Handler\SubscribingHandlerInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
19
use JMS\Serializer\JsonSerializationVisitor;
0 ignored issues
show
Bug introduced by
The type JMS\Serializer\JsonSerializationVisitor was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
20
21
class SupplierHandler implements SubscribingHandlerInterface
22
{
23
    public static function getSubscribingMethods(): array
24
    {
25
        return [
26
            [
27
                'direction' => GraphNavigator::DIRECTION_SERIALIZATION,
28
                'format' => 'json',
29
                'type' => SupplierReadModel::class,
30
                'method' => 'serialize',
31
            ],
32
            [
33
                'direction' => GraphNavigator::DIRECTION_DESERIALIZATION,
34
                'format' => 'json',
35
                'type' => SupplierReadModel::class,
36
                'method' => 'deserialize',
37
            ],
38
        ];
39
    }
40
41
    public function serialize(
42
        JsonSerializationVisitor $visitor,
43
        SupplierReadModel $supplier,
44
        array $type
45
    ): array {
46
        $data = [
47
            'uuid' => $supplier->uuid,
48
            'name' => $supplier->name,
49
            'fullAddress' => $supplier->fullAddress(),
50
            'address' => $supplier->address,
51
            'zipCode' => $supplier->zipCode,
52
            'town' => $supplier->town,
53
            'country' => $supplier->country,
54
            'phone' => $supplier->phone,
55
            'facsimile' => $supplier->facsimile,
56
            'email' => $supplier->email,
57
            'contactName' => $supplier->contact,
58
            'cellPhone' => $supplier->cellphone,
59
            'familyLog' => $supplier->familyLog,
60
            'familyLogId' => $supplier->familyLogId,
61
            'delayDelivery' => $supplier->delayDelivery,
62
            'orderDays' => $supplier->orderDays,
63
            'active' => $supplier->active,
64
        ];
65
66
        return $visitor->visitArray($data, $type);
67
    }
68
}
69