Code Duplication    Length = 21-21 lines in 2 locations

src/Drivers/MailjetDriver.php 2 locations

@@ 143-163 (lines=21) @@
140
     * @throws ApiError
141
     * @throws InvalidNewsletterList
142
     */
143
    public function hasMember(string $email, string $listName = ''): bool
144
    {
145
        $listId = $this->lists->findByName($listName)->getId();
146
147
        $response = $this->client->get(Resources::$Contact, ['ContactsList' => $listId]);
148
149
        if (! $response->success()) {
150
            $this->lastError = $response->getData();
151
            throw ApiError::responseError($response->getReasonPhrase(), 'mailjet', $response->getStatus());
152
        }
153
154
        $contacts = $response->getData();
155
156
        foreach ($contacts as $contact) {
157
            if ($contact['Email'] === $email) {
158
                return true;
159
            }
160
        }
161
162
        return false;
163
    }
164
165
    /**
166
     * @param string $email
@@ 172-192 (lines=21) @@
169
     * @throws ApiError
170
     * @throws InvalidNewsletterList
171
     */
172
    public function isSubscribed(string $email, string $listName = ''): bool
173
    {
174
        $listId = $this->lists->findByName($listName)->getId();
175
176
        $response = $this->client->get(Resources::$ContactGetcontactslists, ['id' => $email]);
177
178
        if (! $response->success()) {
179
            $this->lastError = $response->getData();
180
            throw ApiError::responseError($response->getReasonPhrase(), 'mailjet', $response->getStatus());
181
        }
182
183
        $contactLists = $response->getData();
184
185
        foreach ($contactLists as $list) {
186
            if ($list['ListID'] === (int) $listId && $list['IsUnsub'] === false) {
187
                return true;
188
            }
189
        }
190
191
        return false;
192
    }
193
194
    /**
195
     * @param string $email