SoapDateHandler::getSubscribingMethods()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 21
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 14
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 2
eloc 13
c 1
b 0
f 1
nc 2
nop 0
dl 0
loc 21
ccs 14
cts 14
cp 1
crap 2
rs 9.8333
1
<?php
2
3
namespace DMT\Soap\Serializer;
4
5
use JMS\Serializer\GraphNavigatorInterface;
6
use JMS\Serializer\Handler\DateHandler;
7
use JMS\Serializer\Handler\SubscribingHandlerInterface;
8
9
/**
10
 * Class SoapDateHandler
11
 *
12
 * @package DMT\Soap
13
 */
14
class SoapDateHandler implements SubscribingHandlerInterface
15
{
16
    /**
17
     * @var DateHandler
18
     */
19
    protected $dateHandler;
20
21 19
    public static function getSubscribingMethods()
22
    {
23 19
        $methods = [];
24
25 19
        foreach (['DateTime', 'DateTimeImmutable', 'DateInterval'] as $type) {
26 19
            $methods[] = [
27 19
                'type' => $type,
28 19
                'direction' => GraphNavigatorInterface::DIRECTION_DESERIALIZATION,
29 19
                'format' => 'soap',
30 19
                'method' => 'deserialize' . $type . 'FromXml'
31
            ];
32
33 19
            $methods[] = [
34 19
                'type' => $type,
35 19
                'format' => 'soap',
36 19
                'direction' => GraphNavigatorInterface::DIRECTION_SERIALIZATION,
37 19
                'method' => 'serialize' . $type,
38
            ];
39
        }
40
41 19
        return $methods;
42
    }
43
44 19
    public function __construct()
45
    {
46 19
        $this->dateHandler = new DateHandler();
47 19
    }
48
49 12
    public function __call($name, $arguments)
50
    {
51 12
        return call_user_func([$this->dateHandler, $name], ...$arguments);
52
    }
53
}
54