Mandrill_Senders   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 223
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 17
c 0
b 0
f 0
dl 0
loc 223
rs 10
wmc 8

8 Methods

Rating   Name   Duplication   Size   Complexity  
A addDomain() 0 4 1
A timeSeries() 0 4 1
A getList() 0 4 1
A __construct() 0 3 1
A info() 0 4 1
A domains() 0 4 1
A verifyDomain() 0 4 1
A checkDomain() 0 4 1
1
<?php
2
3
class Mandrill_Senders
4
{
5
6
    private $master;
7
8
    public function __construct(Mandrill $master)
9
    {
10
        $this->master = $master;
11
    }
12
13
    /**
14
     * Return the senders that have tried to use this account.
15
     * @return array an array of sender data, one for each sending addresses used by the account
16
     *     - return[] struct the information on each sending address in the account
17
     *         - address string the sender's email address
18
     *         - created_at string the date and time that the sender was first seen by Mandrill as a UTC date string in YYYY-MM-DD HH:MM:SS format
19
     *         - sent integer the total number of messages sent by this sender
20
     *         - hard_bounces integer the total number of hard bounces by messages by this sender
21
     *         - soft_bounces integer the total number of soft bounces by messages by this sender
22
     *         - rejects integer the total number of rejected messages by this sender
23
     *         - complaints integer the total number of spam complaints received for messages by this sender
24
     *         - unsubs integer the total number of unsubscribe requests received for messages by this sender
25
     *         - opens integer the total number of times messages by this sender have been opened
26
     *         - clicks integer the total number of times tracked URLs in messages by this sender have been clicked
27
     *         - unique_opens integer the number of unique opens for emails sent for this sender
28
     *         - unique_clicks integer the number of unique clicks for emails sent for this sender
29
     */
30
    public function getList()
31
    {
32
        $_params = array();
33
        return $this->master->call('senders/list', $_params);
34
    }
35
36
    /**
37
     * Returns the sender domains that have been added to this account.
38
     * @return array an array of sender domain data, one for each sending domain used by the account
39
     *     - return[] struct the information on each sending domain for the account
40
     *         - domain string the sender domain name
41
     *         - created_at string the date and time that the sending domain was first seen as a UTC string in YYYY-MM-DD HH:MM:SS format
42
     *         - last_tested_at string when the domain's DNS settings were last tested as a UTC string in YYYY-MM-DD HH:MM:SS format
43
     *         - spf struct details about the domain's SPF record
44
     *             - valid boolean whether the domain's SPF record is valid for use with Mandrill
45
     *             - valid_after string when the domain's SPF record will be considered valid for use with Mandrill as a UTC string in YYYY-MM-DD HH:MM:SS format. If set, this indicates that the record is valid now, but was previously invalid, and Mandrill will wait until the record's TTL elapses to start using it.
46
     *             - error string an error describing the spf record, or null if the record is correct
47
     *         - dkim struct details about the domain's DKIM record
48
     *             - valid boolean whether the domain's DKIM record is valid for use with Mandrill
49
     *             - valid_after string when the domain's DKIM record will be considered valid for use with Mandrill as a UTC string in YYYY-MM-DD HH:MM:SS format. If set, this indicates that the record is valid now, but was previously invalid, and Mandrill will wait until the record's TTL elapses to start using it.
50
     *             - error string an error describing the DKIM record, or null if the record is correct
51
     *         - verified_at string if the domain has been verified, this indicates when that verification occurred as a UTC string in YYYY-MM-DD HH:MM:SS format
52
     *         - valid_signing boolean whether this domain can be used to authenticate mail, either for itself or as a custom signing domain. If this is false but spf and dkim are both valid, you will need to verify the domain before using it to authenticate mail
53
     */
54
    public function domains()
55
    {
56
        $_params = array();
57
        return $this->master->call('senders/domains', $_params);
58
    }
59
60
    /**
61
     * Adds a sender domain to your account. Sender domains are added automatically as you
62
      send, but you can use this call to add them ahead of time.
63
     * @param string $domain a domain name
64
     * @return struct information about the domain
0 ignored issues
show
Bug introduced by
The type struct was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
65
     *     - domain string the sender domain name
66
     *     - created_at string the date and time that the sending domain was first seen as a UTC string in YYYY-MM-DD HH:MM:SS format
67
     *     - last_tested_at string when the domain's DNS settings were last tested as a UTC string in YYYY-MM-DD HH:MM:SS format
68
     *     - spf struct details about the domain's SPF record
69
     *         - valid boolean whether the domain's SPF record is valid for use with Mandrill
70
     *         - valid_after string when the domain's SPF record will be considered valid for use with Mandrill as a UTC string in YYYY-MM-DD HH:MM:SS format. If set, this indicates that the record is valid now, but was previously invalid, and Mandrill will wait until the record's TTL elapses to start using it.
71
     *         - error string an error describing the spf record, or null if the record is correct
72
     *     - dkim struct details about the domain's DKIM record
73
     *         - valid boolean whether the domain's DKIM record is valid for use with Mandrill
74
     *         - valid_after string when the domain's DKIM record will be considered valid for use with Mandrill as a UTC string in YYYY-MM-DD HH:MM:SS format. If set, this indicates that the record is valid now, but was previously invalid, and Mandrill will wait until the record's TTL elapses to start using it.
75
     *         - error string an error describing the DKIM record, or null if the record is correct
76
     *     - verified_at string if the domain has been verified, this indicates when that verification occurred as a UTC string in YYYY-MM-DD HH:MM:SS format
77
     *     - valid_signing boolean whether this domain can be used to authenticate mail, either for itself or as a custom signing domain. If this is false but spf and dkim are both valid, you will need to verify the domain before using it to authenticate mail
78
     */
79
    public function addDomain($domain)
80
    {
81
        $_params = array("domain" => $domain);
82
        return $this->master->call('senders/add-domain', $_params);
83
    }
84
85
    /**
86
     * Checks the SPF and DKIM settings for a domain. If you haven't already added this domain to your
87
      account, it will be added automatically.
88
     * @param string $domain a domain name
89
     * @return struct information about the sender domain
90
     *     - domain string the sender domain name
91
     *     - created_at string the date and time that the sending domain was first seen as a UTC string in YYYY-MM-DD HH:MM:SS format
92
     *     - last_tested_at string when the domain's DNS settings were last tested as a UTC string in YYYY-MM-DD HH:MM:SS format
93
     *     - spf struct details about the domain's SPF record
94
     *         - valid boolean whether the domain's SPF record is valid for use with Mandrill
95
     *         - valid_after string when the domain's SPF record will be considered valid for use with Mandrill as a UTC string in YYYY-MM-DD HH:MM:SS format. If set, this indicates that the record is valid now, but was previously invalid, and Mandrill will wait until the record's TTL elapses to start using it.
96
     *         - error string an error describing the spf record, or null if the record is correct
97
     *     - dkim struct details about the domain's DKIM record
98
     *         - valid boolean whether the domain's DKIM record is valid for use with Mandrill
99
     *         - valid_after string when the domain's DKIM record will be considered valid for use with Mandrill as a UTC string in YYYY-MM-DD HH:MM:SS format. If set, this indicates that the record is valid now, but was previously invalid, and Mandrill will wait until the record's TTL elapses to start using it.
100
     *         - error string an error describing the DKIM record, or null if the record is correct
101
     *     - verified_at string if the domain has been verified, this indicates when that verification occurred as a UTC string in YYYY-MM-DD HH:MM:SS format
102
     *     - valid_signing boolean whether this domain can be used to authenticate mail, either for itself or as a custom signing domain. If this is false but spf and dkim are both valid, you will need to verify the domain before using it to authenticate mail
103
     */
104
    public function checkDomain($domain)
105
    {
106
        $_params = array("domain" => $domain);
107
        return $this->master->call('senders/check-domain', $_params);
108
    }
109
110
    /**
111
     * Sends a verification email in order to verify ownership of a domain.
112
      Domain verification is an optional step to confirm ownership of a domain. Once a
113
      domain has been verified in a Mandrill account, other accounts may not have their
114
      messages signed by that domain unless they also verify the domain. This prevents
115
      other Mandrill accounts from sending mail signed by your domain.
116
     * @param string $domain a domain name at which you can receive email
117
     * @param string $mailbox a mailbox at the domain where the verification email should be sent
118
     * @return struct information about the verification that was sent
119
     *     - status string "sent" indicates that the verification has been sent, "already_verified" indicates that the domain has already been verified with your account
120
     *     - domain string the domain name you provided
121
     *     - email string the email address the verification email was sent to
122
     */
123
    public function verifyDomain($domain, $mailbox)
124
    {
125
        $_params = array("domain" => $domain, "mailbox" => $mailbox);
126
        return $this->master->call('senders/verify-domain', $_params);
127
    }
128
129
    /**
130
     * Return more detailed information about a single sender, including aggregates of recent stats
131
     * @param string $address the email address of the sender
132
     * @return struct the detailed information on the sender
133
     *     - address string the sender's email address
134
     *     - created_at string the date and time that the sender was first seen by Mandrill as a UTC date string in YYYY-MM-DD HH:MM:SS format
135
     *     - sent integer the total number of messages sent by this sender
136
     *     - hard_bounces integer the total number of hard bounces by messages by this sender
137
     *     - soft_bounces integer the total number of soft bounces by messages by this sender
138
     *     - rejects integer the total number of rejected messages by this sender
139
     *     - complaints integer the total number of spam complaints received for messages by this sender
140
     *     - unsubs integer the total number of unsubscribe requests received for messages by this sender
141
     *     - opens integer the total number of times messages by this sender have been opened
142
     *     - clicks integer the total number of times tracked URLs in messages by this sender have been clicked
143
     *     - stats struct an aggregate summary of the sender's sending stats
144
     *         - today struct stats for this sender so far today
145
     *             - sent integer the number of emails sent for this sender so far today
146
     *             - hard_bounces integer the number of emails hard bounced for this sender so far today
147
     *             - soft_bounces integer the number of emails soft bounced for this sender so far today
148
     *             - rejects integer the number of emails rejected for sending this sender so far today
149
     *             - complaints integer the number of spam complaints for this sender so far today
150
     *             - unsubs integer the number of unsubscribes for this sender so far today
151
     *             - opens integer the number of times emails have been opened for this sender so far today
152
     *             - unique_opens integer the number of unique opens for emails sent for this sender so far today
153
     *             - clicks integer the number of URLs that have been clicked for this sender so far today
154
     *             - unique_clicks integer the number of unique clicks for emails sent for this sender so far today
155
     *         - last_7_days struct stats for this sender in the last 7 days
156
     *             - sent integer the number of emails sent for this sender in the last 7 days
157
     *             - hard_bounces integer the number of emails hard bounced for this sender in the last 7 days
158
     *             - soft_bounces integer the number of emails soft bounced for this sender in the last 7 days
159
     *             - rejects integer the number of emails rejected for sending this sender in the last 7 days
160
     *             - complaints integer the number of spam complaints for this sender in the last 7 days
161
     *             - unsubs integer the number of unsubscribes for this sender in the last 7 days
162
     *             - opens integer the number of times emails have been opened for this sender in the last 7 days
163
     *             - unique_opens integer the number of unique opens for emails sent for this sender in the last 7 days
164
     *             - clicks integer the number of URLs that have been clicked for this sender in the last 7 days
165
     *             - unique_clicks integer the number of unique clicks for emails sent for this sender in the last 7 days
166
     *         - last_30_days struct stats for this sender in the last 30 days
167
     *             - sent integer the number of emails sent for this sender in the last 30 days
168
     *             - hard_bounces integer the number of emails hard bounced for this sender in the last 30 days
169
     *             - soft_bounces integer the number of emails soft bounced for this sender in the last 30 days
170
     *             - rejects integer the number of emails rejected for sending this sender in the last 30 days
171
     *             - complaints integer the number of spam complaints for this sender in the last 30 days
172
     *             - unsubs integer the number of unsubscribes for this sender in the last 30 days
173
     *             - opens integer the number of times emails have been opened for this sender in the last 30 days
174
     *             - unique_opens integer the number of unique opens for emails sent for this sender in the last 30 days
175
     *             - clicks integer the number of URLs that have been clicked for this sender in the last 30 days
176
     *             - unique_clicks integer the number of unique clicks for emails sent for this sender in the last 30 days
177
     *         - last_60_days struct stats for this sender in the last 60 days
178
     *             - sent integer the number of emails sent for this sender in the last 60 days
179
     *             - hard_bounces integer the number of emails hard bounced for this sender in the last 60 days
180
     *             - soft_bounces integer the number of emails soft bounced for this sender in the last 60 days
181
     *             - rejects integer the number of emails rejected for sending this sender in the last 60 days
182
     *             - complaints integer the number of spam complaints for this sender in the last 60 days
183
     *             - unsubs integer the number of unsubscribes for this sender in the last 60 days
184
     *             - opens integer the number of times emails have been opened for this sender in the last 60 days
185
     *             - unique_opens integer the number of unique opens for emails sent for this sender in the last 60 days
186
     *             - clicks integer the number of URLs that have been clicked for this sender in the last 60 days
187
     *             - unique_clicks integer the number of unique clicks for emails sent for this sender in the last 60 days
188
     *         - last_90_days struct stats for this sender in the last 90 days
189
     *             - sent integer the number of emails sent for this sender in the last 90 days
190
     *             - hard_bounces integer the number of emails hard bounced for this sender in the last 90 days
191
     *             - soft_bounces integer the number of emails soft bounced for this sender in the last 90 days
192
     *             - rejects integer the number of emails rejected for sending this sender in the last 90 days
193
     *             - complaints integer the number of spam complaints for this sender in the last 90 days
194
     *             - unsubs integer the number of unsubscribes for this sender in the last 90 days
195
     *             - opens integer the number of times emails have been opened for this sender in the last 90 days
196
     *             - unique_opens integer the number of unique opens for emails sent for this sender in the last 90 days
197
     *             - clicks integer the number of URLs that have been clicked for this sender in the last 90 days
198
     *             - unique_clicks integer the number of unique clicks for emails sent for this sender in the last 90 days
199
     */
200
    public function info($address)
201
    {
202
        $_params = array("address" => $address);
203
        return $this->master->call('senders/info', $_params);
204
    }
205
206
    /**
207
     * Return the recent history (hourly stats for the last 30 days) for a sender
208
     * @param string $address the email address of the sender
209
     * @return array the array of history information
210
     *     - return[] struct the stats for a single hour
211
     *         - time string the hour as a UTC date string in YYYY-MM-DD HH:MM:SS format
212
     *         - sent integer the number of emails that were sent during the hour
213
     *         - hard_bounces integer the number of emails that hard bounced during the hour
214
     *         - soft_bounces integer the number of emails that soft bounced during the hour
215
     *         - rejects integer the number of emails that were rejected during the hour
216
     *         - complaints integer the number of spam complaints received during the hour
217
     *         - opens integer the number of emails opened during the hour
218
     *         - unique_opens integer the number of unique opens generated by messages sent during the hour
219
     *         - clicks integer the number of tracked URLs clicked during the hour
220
     *         - unique_clicks integer the number of unique clicks generated by messages sent during the hour
221
     */
222
    public function timeSeries($address)
223
    {
224
        $_params = array("address" => $address);
225
        return $this->master->call('senders/time-series', $_params);
226
    }
227
}
228