ShippingService   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Importance

Changes 2
Bugs 1 Features 0
Metric Value
eloc 12
c 2
b 1
f 0
dl 0
loc 41
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getShippingMethods() 0 14 1
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\Services;
14
15
use Etrias\EwarehousingConnector\Client\EwarehousingClient;
16
use Etrias\EwarehousingConnector\Response\ShippingResponse;
17
use Etrias\EwarehousingConnector\Serializer\ServiceTrait;
18
use GuzzleHttp\RequestOptions;
19
use JMS\Serializer\SerializerInterface;
20
21
class ShippingService implements ShippingServiceInterface
22
{
23
    use ServiceTrait;
24
25
    /** @var EwarehousingClient */
26
    protected $client;
27
28
    /** @var SerializerInterface */
29
    protected $serializer;
30
31
    /**
32
     * OrderService constructor.
33
     *
34
     * @param EwarehousingClient  $client
35
     * @param SerializerInterface $serializer
36
     */
37
    public function __construct(EwarehousingClient $client, SerializerInterface $serializer)
38
    {
39
        $this->client = $client;
40
        $this->serializer = $serializer;
41
    }
42
43
    /**
44
     * {@inheritdoc}
45
     *
46
     * @return ShippingResponse[]
47
     */
48
    public function getShippingMethods(
49
        $distributor = null,
50
        $code = null,
51
        $type = null
52
    ) {
53
        $data = [
54
            'distributor' => $distributor,
55
            'code' => $code,
56
            'type' => $type
57
        ];
58
59
        $guzzleResponse = $this->client->get('1/shippingmethods', [RequestOptions::QUERY => $data]);
60
61
        return $this->deserializeResponse($guzzleResponse, 'array<'.ShippingResponse::class.'>');
62
    }
63
64
}
65