Completed
Push — master ( 39762b...5dff0a )
by Samuel
12s queued 11s
created

TimeZoneService   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 91.67%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 4
dl 0
loc 30
ccs 11
cts 12
cp 0.9167
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A process() 0 16 2
1
<?php
2
3
/*
4
 * This file is part of the Ivory Google Map package.
5
 *
6
 * (c) Eric GELOEN <[email protected]>
7
 *
8
 * For the full copyright and license information, please read the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Ivory\GoogleMap\Service\TimeZone;
13
14
use Http\Client\HttpClient;
15
use Http\Message\MessageFactory;
16
use Ivory\GoogleMap\Service\AbstractSerializableService;
17
use Ivory\GoogleMap\Service\TimeZone\Request\TimeZoneRequestInterface;
18
use Ivory\GoogleMap\Service\TimeZone\Response\TimeZoneResponse;
19
use Ivory\Serializer\Context\Context;
20
use Ivory\Serializer\Naming\SnakeCaseNamingStrategy;
21
use Ivory\Serializer\SerializerInterface;
22
23
/**
24
 * @author GeLo <[email protected]>
25
 */
26
class TimeZoneService extends AbstractSerializableService
27
{
28 4
    public function __construct(
29
        HttpClient $client,
30
        MessageFactory $messageFactory,
31
        SerializerInterface $serializer = null
32
    ) {
33 4
        parent::__construct('https://maps.googleapis.com/maps/api/timezone', $client, $messageFactory, $serializer);
34 4
    }
35
36
    /**
37
     * @return TimeZoneResponse
38
     */
39 4
    public function process(TimeZoneRequestInterface $request)
40
    {
41 4
        $httpRequest = $this->createRequest($request);
42 4
        $httpResponse = $this->getClient()->sendRequest($httpRequest);
43
44 4
        $context = new Context();
45
46 4
        if (self::FORMAT_XML === $this->getFormat()) {
47
            $context->setNamingStrategy(new SnakeCaseNamingStrategy());
48
        }
49
50 4
        $response = $this->deserialize($httpResponse, TimeZoneResponse::class, $context);
51 4
        $response->setRequest($request);
52
53 4
        return $response;
54
    }
55
}
56