Code Duplication    Length = 10-14 lines in 2 locations

src/Newsletter.php 2 locations

@@ 148-161 (lines=14) @@
145
        return true;
146
    }
147
148
    public function unsubscribe(string $email, string $listName = '')
149
    {
150
        $list = $this->lists->findByName($listName);
151
152
        $response = $this->mailChimp->patch("lists/{$list->getId()}/members/{$this->getSubscriberHash($email)}", [
153
            'status' => 'unsubscribed',
154
        ]);
155
156
        if (! $this->lastActionSucceeded()) {
157
            return false;
158
        }
159
160
        return $response;
161
    }
162
163
    public function updateEmailAddress(string $currentEmailAddress, string $newEmailAddress, string $listName = '')
164
    {
@@ 163-172 (lines=10) @@
160
        return $response;
161
    }
162
163
    public function updateEmailAddress(string $currentEmailAddress, string $newEmailAddress, string $listName = '')
164
    {
165
        $list = $this->lists->findByName($listName);
166
167
        $response = $this->mailChimp->patch("lists/{$list->getId()}/members/{$this->getSubscriberHash($currentEmailAddress)}", [
168
            'email_address' => $newEmailAddress,
169
        ]);
170
171
        return $response;
172
    }
173
174
    public function delete(string $email, string $listName = '')
175
    {