Code Duplication    Length = 20-20 lines in 2 locations

src/Drivers/MailjetDriver.php 2 locations

@@ 134-153 (lines=20) @@
131
     * @throws ApiError
132
     * @throws InvalidNewsletterList
133
     */
134
    public function hasMember(string $email, string $listName = ''): bool
135
    {
136
        $listId = $this->lists->findByName($listName)->getId();
137
138
        $response = $this->client->get(Resources::$Contact, ['ContactsList' => $listId]);
139
140
        if (! $response->success()) {
141
            throw ApiError::responseError($response->getReasonPhrase(), 'mailjet', $response->getStatus());
142
        }
143
144
        $contacts = $response->getData();
145
146
        foreach ($contacts as $contact) {
147
            if ($contact['Email'] === $email) {
148
                return true;
149
            }
150
        }
151
152
        return false;
153
    }
154
155
    /**
156
     * @param string $email
@@ 162-181 (lines=20) @@
159
     * @throws ApiError
160
     * @throws InvalidNewsletterList
161
     */
162
    public function isSubscribed(string $email, string $listName = ''): bool
163
    {
164
        $listId = $this->lists->findByName($listName)->getId();
165
166
        $response = $this->client->get(Resources::$ContactGetcontactslists, ['id' => $email]);
167
168
        if (! $response->success()) {
169
            throw ApiError::responseError($response->getReasonPhrase(), 'mailjet', $response->getStatus());
170
        }
171
172
        $contactLists = $response->getData();
173
174
        foreach ($contactLists as $list) {
175
            if ($list['ListID'] === $listId && $list['IsUnsub'] !== true) {
176
                return true;
177
            }
178
        }
179
180
        return false;
181
    }
182
183
    /**
184
     * @param string $email