DateHandler::getSubscribingMethods()   A
last analyzed

Complexity

Conditions 4
Paths 5

Size

Total Lines 26
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 4
eloc 16
c 1
b 0
f 0
nc 5
nop 0
dl 0
loc 26
rs 9.7333
1
<?php
2
3
/*
4
 * This file is part of PHP CS Fixer.
5
 *
6
 * (c) Fabien Potencier <[email protected]>
7
 *     Dariusz Rumiński <[email protected]>
8
 *
9
 * This source file is subject to the MIT license that is bundled
10
 * with this source code in the file LICENSE.
11
 */
12
13
namespace Etrias\EwarehousingConnector\Serializer\Handler;
14
15
use JMS\Serializer\GraphNavigator;
16
use JMS\Serializer\Handler\DateHandler as BaseDateHandler;
17
18
class DateHandler extends BaseDateHandler
19
{
20
    public static function getSubscribingMethods()
21
    {
22
        $methods = [];
23
        $deserializationTypes = ['DateTime', 'DateTimeImmutable', 'DateInterval'];
24
        $serialisationTypes = ['DateTime', 'DateTimeImmutable', 'DateInterval'];
25
26
        foreach (['array'] as $format) {
27
            foreach ($deserializationTypes as $type) {
28
                $methods[] = [
29
                    'type' => $type,
30
                    'direction' => GraphNavigator::DIRECTION_DESERIALIZATION,
31
                    'format' => $format,
32
                ];
33
            }
34
35
            foreach ($serialisationTypes as $type) {
36
                $methods[] = [
37
                    'type' => $type,
38
                    'format' => $format,
39
                    'direction' => GraphNavigator::DIRECTION_SERIALIZATION,
40
                    'method' => 'serialize'.$type,
41
                ];
42
            }
43
        }
44
45
        return $methods;
46
    }
47
}
48