Code Duplication    Length = 13-15 lines in 2 locations

src/MailingList.php 2 locations

@@ 56-70 (lines=15) @@
53
    /**
54
     * @throws \Exception
55
     */
56
    public function isOnList(string $email) : bool
57
    {
58
        try {
59
            $this->api->get('lists/'.$this->id().'/members/'.$this->support->hashEmail($email));
60
61
            return true;
62
        } catch (\Exception $e) {
63
            # Email address isn't on this list
64
            if (str_contains($e->getMessage(), 'Resource Not Found')) {
65
                return false;
66
            }
67
68
            throw $e;
69
        }
70
    }
71
72
    /**
73
     * @param string        $email
@@ 117-129 (lines=13) @@
114
     * @throws EmailAddressNotSubscribed
115
     * @throws \Exception
116
     */
117
    public function subscriberInfo(string $email) : Collection
118
    {
119
        try {
120
            return $this->api->get('lists/'.$this->id().'/members/'.$this->support->hashEmail($email));
121
        } catch (\Exception $e) {
122
            # Email address isn't on this list
123
            if (str_contains($e->getMessage(), 'Resource Not Found')) {
124
                throw new EmailAddressNotSubscribed;
125
            }
126
127
            throw $e;
128
        }
129
    }
130
131
    /**
132
     * Updates a subscriber if the email address is already