Code Duplication    Length = 15-15 lines in 2 locations

src/Easychimp.php 2 locations

@@ 26-40 (lines=15) @@
23
     *
24
     * @return boolean
25
     */
26
    public function isSubscribed($listId, $email)
27
    {
28
        try {
29
            $result = $this->api->get('lists/'.$listId.'/members/'.$this->hashEmail($email));
30
31
            return $result->get('status') == 'subscribed';
32
        } catch (\Exception $e) {
33
            # Email address isn't on this list
34
            if (str_contains($e->getMessage(), 'Resource Not Found')) {
35
                return false;
36
            }
37
38
            throw $e;
39
        }
40
    }
41
42
    /**
43
     * @param $listId
@@ 89-103 (lines=15) @@
86
     *
87
     * @return boolean
88
     */
89
    public function unsubscribe($listId, $email)
90
    {
91
        try {
92
            $result = $this->api->delete('lists/'.$listId.'/members/'.$this->hashEmail($email));
93
94
            return $result->count() == 0;
95
        } catch (\Exception $e) {
96
            # Email address isn't on this list
97
            if (str_contains($e->getMessage(), 'Resource Not Found')) {
98
                return true;
99
            }
100
101
            throw $e;
102
        }
103
    }
104
105
    /**
106
     * @param $listId