Code Duplication    Length = 15-19 lines in 4 locations

src/Api/Cart.php 1 location

@@ 31-49 (lines=19) @@
28
     *
29
     * @return Cart|ResponseInterface
30
     */
31
    public function get(int $id)
32
    {
33
        if (empty($id)) {
34
            throw new InvalidArgumentException('Id cannot be empty');
35
        }
36
37
        $response = $this->httpGet("/api/v1/carts/{$id}");
38
39
        if (!$this->hydrator) {
40
            return $response;
41
        }
42
43
        // Use any valid status code here
44
        if (200 !== $response->getStatusCode()) {
45
            $this->handleErrors($response);
46
        }
47
48
        return $this->hydrator->hydrate($response, Model::class);
49
    }
50
51
    /**
52
     * @param string $message

src/Api/Product.php 3 locations

@@ 23-37 (lines=15) @@
20
 */
21
final class Product extends HttpApi
22
{
23
    public function get(string $productCode)
24
    {
25
        $response = $this->httpGet("/api/v1/products/{$productCode}");
26
27
        if (!$this->hydrator) {
28
            return $response;
29
        }
30
31
        // Use any valid status code here
32
        if (200 !== $response->getStatusCode()) {
33
            $this->handleErrors($response);
34
        }
35
36
        return $this->hydrator->hydrate($response, Model::class);
37
    }
38
39
    /**
40
     * @param array $params
@@ 46-60 (lines=15) @@
43
     *
44
     * @return ProductCollection|ResponseInterface
45
     */
46
    public function getAll(array $params = [])
47
    {
48
        $response = $this->httpGet('/api/v1/products/', $params);
49
50
        if (!$this->hydrator) {
51
            return $response;
52
        }
53
54
        // Use any valid status code here
55
        if (200 !== $response->getStatusCode()) {
56
            $this->handleErrors($response);
57
        }
58
59
        return $this->hydrator->hydrate($response, ProductCollection::class);
60
    }
61
62
    /**
63
     * @param string $productCode
@@ 70-84 (lines=15) @@
67
     *
68
     * @throws Exception\DomainException
69
     */
70
    public function getVariants(string $productCode, array $params = [])
71
    {
72
        $response = $this->httpGet("/api/v1/products/{$productCode}/variants/", $params);
73
74
        if (!$this->hydrator) {
75
            return $response;
76
        }
77
78
        // Use any valid status code here
79
        if (200 !== $response->getStatusCode()) {
80
            $this->handleErrors($response);
81
        }
82
83
        return $this->hydrator->hydrate($response, VariantCollection::class);
84
    }
85
}
86