Completed
Pull Request — master (#11)
by Bas
06:18
created

SoapDateHandler   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 17
dl 0
loc 38
ccs 19
cts 19
cp 1
rs 10
c 0
b 0
f 0
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getSubscribingMethods() 0 21 2
A __construct() 0 3 1
A __call() 0 3 1
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 14
    public static function getSubscribingMethods()
22
    {
23 14
        $methods = [];
24
25 14
        foreach (['DateTime', 'DateTimeImmutable', 'DateInterval'] as $type) {
26 14
            $methods[] = [
27 14
                'type' => $type,
28 14
                'direction' => GraphNavigatorInterface::DIRECTION_DESERIALIZATION,
29 14
                'format' => 'soap',
30 14
                'method' => 'deserialize' . $type . 'FromXml'
31
            ];
32
33 14
            $methods[] = [
34 14
                'type' => $type,
35 14
                'format' => 'soap',
36 14
                'direction' => GraphNavigatorInterface::DIRECTION_SERIALIZATION,
37 14
                'method' => 'serialize' . $type,
38
            ];
39
        }
40
41 14
        return $methods;
42
    }
43
44 14
    public function __construct()
45
    {
46 14
        $this->dateHandler = new DateHandler();
47 14
    }
48
49 8
    public function __call($name, $arguments)
50
    {
51 8
        return call_user_func([$this->dateHandler, $name], ...$arguments);
52
    }
53
}
54