Code Duplication    Length = 31-41 lines in 5 locations

src/Service/Direction/DirectionService.php 1 location

@@ 26-61 (lines=36) @@
23
/**
24
 * @author GeLo <[email protected]>
25
 */
26
class DirectionService extends AbstractSerializableService
27
{
28
    public function __construct(
29
        HttpClient $client,
30
        MessageFactory $messageFactory,
31
        SerializerInterface $serializer = null
32
    ) {
33
        parent::__construct('https://maps.googleapis.com/maps/api/directions', $client, $messageFactory, $serializer);
34
    }
35
36
    /**
37
     * @return DirectionResponse
38
     */
39
    public function route(DirectionRequestInterface $request)
40
    {
41
        $httpRequest = $this->createRequest($request);
42
        $httpResponse = $this->getClient()->sendRequest($httpRequest);
43
44
        $response = $this->deserialize(
45
            $httpResponse,
46
            DirectionResponse::class,
47
            (new Context())->setNamingStrategy(new SnakeCaseNamingStrategy())
48
        );
49
50
        $response->setRequest($request);
51
52
        return $response;
53
    }
54
}
55

src/Service/DistanceMatrix/DistanceMatrixService.php 1 location

@@ 26-66 (lines=41) @@
23
/**
24
 * @author GeLo <[email protected]>
25
 */
26
class DistanceMatrixService extends AbstractSerializableService
27
{
28
    public function __construct(
29
        HttpClient $client,
30
        MessageFactory $messageFactory,
31
        SerializerInterface $serializer = null
32
    ) {
33
        parent::__construct(
34
            'https://maps.googleapis.com/maps/api/distancematrix',
35
            $client,
36
            $messageFactory,
37
            $serializer
38
        );
39
    }
40
41
    /**
42
     * @return DistanceMatrixResponse
43
     */
44
    public function process(DistanceMatrixRequestInterface $request)
45
    {
46
        $httpRequest = $this->createRequest($request);
47
        $httpResponse = $this->getClient()->sendRequest($httpRequest);
48
49
        $response = $this->deserialize(
50
            $httpResponse,
51
            DistanceMatrixResponse::class,
52
            (new Context())->setNamingStrategy(new SnakeCaseNamingStrategy())
53
        );
54
55
        $response->setRequest($request);
56
57
        return $response;
58
    }
59
}
60

src/Service/Elevation/ElevationService.php 1 location

@@ 24-54 (lines=31) @@
21
/**
22
 * @author GeLo <[email protected]>
23
 */
24
class ElevationService extends AbstractSerializableService
25
{
26
    public function __construct(
27
        HttpClient $client,
28
        MessageFactory $messageFactory,
29
        SerializerInterface $serializer = null
30
    ) {
31
        parent::__construct('https://maps.googleapis.com/maps/api/elevation', $client, $messageFactory, $serializer);
32
    }
33
34
    /**
35
     * @return ElevationResponse
36
     */
37
    public function process(ElevationRequestInterface $request)
38
    {
39
        $httpRequest = $this->createRequest($request);
40
        $httpResponse = $this->getClient()->sendRequest($httpRequest);
41
42
        $response = $this->deserialize($httpResponse, ElevationResponse::class);
43
        $response->setRequest($request);
44
45
        return $response;
46
    }
47
}
48

src/Service/Geocoder/GeocoderService.php 1 location

@@ 26-66 (lines=41) @@
23
/**
24
 * @author GeLo <[email protected]>
25
 */
26
class GeocoderService extends AbstractSerializableService
27
{
28
    public function __construct(
29
        HttpClient $client,
30
        MessageFactory $messageFactory,
31
        SerializerInterface $serializer = null
32
    ) {
33
        parent::__construct(
34
            'https://maps.googleapis.com/maps/api/geocode',
35
            $client,
36
            $messageFactory,
37
            $serializer
38
        );
39
    }
40
41
    /**
42
     * @return GeocoderResponse
43
     */
44
    public function geocode(GeocoderRequestInterface $request)
45
    {
46
        $httpRequest = $this->createRequest($request);
47
        $httpResponse = $this->getClient()->sendRequest($httpRequest);
48
49
        $response = $this->deserialize(
50
            $httpResponse,
51
            GeocoderResponse::class,
52
            (new Context())->setNamingStrategy(new SnakeCaseNamingStrategy())
53
        );
54
55
        $response->setRequest($request);
56
57
        return $response;
58
    }
59
}
60

src/Service/Place/Detail/PlaceDetailService.php 1 location

@@ 26-66 (lines=41) @@
23
/**
24
 * @author GeLo <[email protected]>
25
 */
26
class PlaceDetailService extends AbstractSerializableService
27
{
28
    public function __construct(
29
        HttpClient $client,
30
        MessageFactory $messageFactory,
31
        SerializerInterface $serializer = null
32
    ) {
33
        parent::__construct(
34
            'https://maps.googleapis.com/maps/api/place/details',
35
            $client,
36
            $messageFactory,
37
            $serializer
38
        );
39
    }
40
41
    /**
42
     * @return PlaceDetailResponse
43
     */
44
    public function process(PlaceDetailRequestInterface $request)
45
    {
46
        $httpRequest = $this->createRequest($request);
47
        $httpResponse = $this->getClient()->sendRequest($httpRequest);
48
49
        $response = $this->deserialize(
50
            $httpResponse,
51
            PlaceDetailResponse::class,
52
            (new Context())->setNamingStrategy(new SnakeCaseNamingStrategy())
53
        );
54
55
        $response->setRequest($request);
56
57
        return $response;
58
    }
59
}
60