Code Duplication    Length = 22-22 lines in 2 locations

Services/CustomerService.php 1 location

@@ 107-128 (lines=22) @@
104
     *
105
     * @return null|string
106
     */
107
    public function read(Customer $customer = null, $count = 50, $offset = 0)
108
    {
109
        $method = RequestTypes::$GET;
110
111
        if ($customer instanceof Customer) {
112
            $resource = '/customers/'.$customer->getId();
113
        } else {
114
            $resource = '/customers';
115
        }
116
117
        $resource .= '?count='.$count.'&offset='.$offset;
118
119
        $data = [];
120
121
        try {
122
            $request = $this->mailChimp->doRequest($method, $data, $resource);
123
        } catch (CustomerNotFoundException $e) {
124
            return null;
125
        }
126
127
        return $request->getBody()->getContents();
128
    }
129
130
    /**
131
     * Delete a customer from MailChimp

Services/ProductService.php 1 location

@@ 104-125 (lines=22) @@
101
     *
102
     * @return null|string
103
     */
104
    public function read(Product $product = null, $count = 50, $offset = 0)
105
    {
106
        $method = RequestTypes::$GET;
107
108
        if ($product instanceof Product) {
109
            $resource = '/products/'.$product->getId();
110
        } else {
111
            $resource = '/products';
112
        }
113
114
        $resource .= '?count='.$count.'&offset='.$offset;
115
116
        $data = [];
117
118
        try {
119
            $request = $this->mailChimp->doRequest($method, $data, $resource);
120
        } catch (ProductNotFoundException $e) {
121
            return null;
122
        }
123
124
        return $request->getBody()->getContents();
125
    }
126
127
    /**
128
     * Delete product from MailChimp