Passed
Push — master ( d156dd...acd975 )
by Thomas
04:20 queued 01:05
created

Mandrill_Urls::search()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 4
rs 10
1
<?php
2
3
class Mandrill_Urls
4
{
5
6
    public function __construct(Mandrill $master)
7
    {
8
        $this->master = $master;
0 ignored issues
show
Bug Best Practice introduced by
The property master does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
9
    }
10
11
    /**
12
     * Get the 100 most clicked URLs
13
     * @return array the 100 most clicked URLs and their stats
14
     *     - return[] struct the individual URL stats
15
     *         - url string the URL to be tracked
16
     *         - sent integer the number of emails that contained the URL
17
     *         - clicks integer the number of times the URL has been clicked from a tracked email
18
     *         - unique_clicks integer the number of unique emails that have generated clicks for this URL
19
     */
20
    public function getList()
21
    {
22
        $_params = array();
23
        return $this->master->call('urls/list', $_params);
24
    }
25
26
    /**
27
     * Return the 100 most clicked URLs that match the search query given
28
     * @param string $q a search query
29
     * @return array the 100 most clicked URLs matching the search query
30
     *     - return[] struct the URL matching the query
31
     *         - url string the URL to be tracked
32
     *         - sent integer the number of emails that contained the URL
33
     *         - clicks integer the number of times the URL has been clicked from a tracked email
34
     *         - unique_clicks integer the number of unique emails that have generated clicks for this URL
35
     */
36
    public function search($q)
37
    {
38
        $_params = array("q" => $q);
39
        return $this->master->call('urls/search', $_params);
40
    }
41
42
    /**
43
     * Return the recent history (hourly stats for the last 30 days) for a url
44
     * @param string $url an existing URL
45
     * @return array the array of history information
46
     *     - return[] struct the information for a single hour
47
     *         - time string the hour as a UTC date string in YYYY-MM-DD HH:MM:SS format
48
     *         - sent integer the number of emails that were sent with the URL during the hour
49
     *         - clicks integer the number of times the URL was clicked during the hour
50
     *         - unique_clicks integer the number of unique clicks generated for emails sent with this URL during the hour
51
     */
52
    public function timeSeries($url)
53
    {
54
        $_params = array("url" => $url);
55
        return $this->master->call('urls/time-series', $_params);
56
    }
57
58
    /**
59
     * Get the list of tracking domains set up for this account
60
     * @return array the tracking domains and their status
61
     *     - return[] struct the individual tracking domain
62
     *         - domain string the tracking domain name
63
     *         - created_at string the date and time that the tracking domain was added as a UTC string in YYYY-MM-DD HH:MM:SS format
64
     *         - 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
65
     *         - cname struct details about the domain's CNAME record
66
     *             - valid boolean whether the domain's CNAME record is valid for use with Mandrill
67
     *             - valid_after string when the domain's CNAME 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.
68
     *             - error string an error describing the CNAME record, or null if the record is correct
69
     *         - valid_tracking boolean whether this domain can be used as a tracking domain for email.
70
     */
71
    public function trackingDomains()
72
    {
73
        $_params = array();
74
        return $this->master->call('urls/tracking-domains', $_params);
75
    }
76
77
    /**
78
     * Add a tracking domain to your account
79
     * @param string $domain a domain name
80
     * @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...
81
     *     - domain string the tracking domain name
82
     *     - created_at string the date and time that the tracking domain was added as a UTC string in YYYY-MM-DD HH:MM:SS format
83
     *     - 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
84
     *     - cname struct details about the domain's CNAME record
85
     *         - valid boolean whether the domain's CNAME record is valid for use with Mandrill
86
     *         - valid_after string when the domain's CNAME 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.
87
     *         - error string an error describing the CNAME record, or null if the record is correct
88
     *     - valid_tracking boolean whether this domain can be used as a tracking domain for email.
89
     */
90
    public function addTrackingDomain($domain)
91
    {
92
        $_params = array("domain" => $domain);
93
        return $this->master->call('urls/add-tracking-domain', $_params);
94
    }
95
96
    /**
97
     * Checks the CNAME settings for a tracking domain. The domain must have been added already with the add-tracking-domain call
98
     * @param string $domain an existing tracking domain name
99
     * @return struct information about the tracking domain
100
     *     - domain string the tracking domain name
101
     *     - created_at string the date and time that the tracking domain was added as a UTC string in YYYY-MM-DD HH:MM:SS format
102
     *     - 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
103
     *     - cname struct details about the domain's CNAME record
104
     *         - valid boolean whether the domain's CNAME record is valid for use with Mandrill
105
     *         - valid_after string when the domain's CNAME 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.
106
     *         - error string an error describing the CNAME record, or null if the record is correct
107
     *     - valid_tracking boolean whether this domain can be used as a tracking domain for email.
108
     */
109
    public function checkTrackingDomain($domain)
110
    {
111
        $_params = array("domain" => $domain);
112
        return $this->master->call('urls/check-tracking-domain', $_params);
113
    }
114
}
115