Code Duplication    Length = 14-15 lines in 4 locations

src/Api/Product.php 1 location

@@ 55-69 (lines=15) @@
52
     *
53
     * @return Model|ResponseInterface
54
     */
55
    public function create(string $productCode, array $params = [])
56
    {
57
        $params['code'] = $productCode;
58
        $response = $this->httpPost('/api/v1/products/', $params);
59
        if (!$this->hydrator) {
60
            return $response;
61
        }
62
63
        // Use any valid status code here
64
        if (201 !== $response->getStatusCode()) {
65
            $this->handleErrors($response);
66
        }
67
68
        return $this->hydrator->hydrate($response, Model::class);
69
    }
70
71
    /**
72
     * Update a product partially.

src/Api/Product/Taxon.php 1 location

@@ 74-88 (lines=15) @@
71
     *
72
     * @return Model|ResponseInterface
73
     */
74
    public function create(string $code, array $params = [])
75
    {
76
        $params = $this->validateAndGetParams($code, $params);
77
        $response = $this->httpPost('/api/v1/taxons/', $params);
78
        if (!$this->hydrator) {
79
            return $response;
80
        }
81
82
        // Use any valid status code here
83
        if (201 !== $response->getStatusCode()) {
84
            $this->handleErrors($response);
85
        }
86
87
        return $this->hydrator->hydrate($response, Model::class);
88
    }
89
90
    /**
91
     * Update a taxon partially.

src/Api/Product/Variant.php 2 locations

@@ 29-42 (lines=14) @@
26
     *
27
     * @return ResponseInterface|VariantCollection
28
     */
29
    public function getAll(string $productCode, array $params = [])
30
    {
31
        $response = $this->httpGet(\sprintf('/api/v1/products/%s/variants/', $productCode), $params);
32
        if (!$this->hydrator) {
33
            return $response;
34
        }
35
36
        // Use any valid status code here
37
        if (200 !== $response->getStatusCode()) {
38
            $this->handleErrors($response);
39
        }
40
41
        return $this->hydrator->hydrate($response, VariantCollection::class);
42
    }
43
44
    /**
45
     * {@link https://docs.sylius.com/en/1.3/api/product_variants.html#getting-a-single-product-variant}.
@@ 73-87 (lines=15) @@
70
     *
71
     * @return Model|ResponseInterface
72
     */
73
    public function create(string $productCode, string $code, array $params = [])
74
    {
75
        $params['code'] = $code;
76
        $response = $this->httpPost(\sprintf('/api/v1/products/%s/variants/', $productCode), $params);
77
        if (!$this->hydrator) {
78
            return $response;
79
        }
80
81
        // Use any valid status code here
82
        if (201 !== $response->getStatusCode()) {
83
            $this->handleErrors($response);
84
        }
85
86
        return $this->hydrator->hydrate($response, Model::class);
87
    }
88
89
    /**
90
     * Update a product partially.