Code Duplication    Length = 10-11 lines in 5 locations

SEOstats/Services/Social.php 5 locations

@@ 53-63 (lines=11) @@
50
     * @return        array      Returns an array of total counts for 1. all Facebook interactions,
51
     *                           2. FB shares, 3. FB likes, 4. FB comments and 5. outgoing clicks for a URL.
52
     */
53
    public static function getFacebookShares($url = false)
54
    {
55
        $url     = parent::getUrl($url);
56
        $fql     = sprintf('SELECT total_count, share_count, like_count, comment_count, commentsbox_count, click_count FROM link_stat WHERE url="%s"', $url);
57
        $dataUrl = sprintf(Config\Services::FB_LINKSTATS_URL, rawurlencode($fql));
58
59
        $jsonData = parent::_getPage($dataUrl);
60
        $phpArray = Helper\Json::decode($jsonData, true);
61
62
        return isset($phpArray[0]) ? $phpArray[0] : parent::noDataDefaultValue();
63
    }
64
65
    /**
66
     * Returns the total count of mentions of $url on Twitter.
@@ 73-82 (lines=10) @@
70
     * @return       integer            Returns the total count of Twitter mentions for a URL.
71
     * @link         https://dev.twitter.com/discussions/5653#comment-11514
72
     */
73
    public static function getTwitterShares($url = false)
74
    {
75
        $url     = parent::getUrl($url);
76
        $dataUrl = sprintf(Config\Services::TWEETCOUNT_URL, urlencode($url));
77
78
        $jsonData = parent::_getPage($dataUrl);
79
        $phpArray = Helper\Json::decode($jsonData, true);
80
81
        return isset($phpArray['count']) ? intval($phpArray['count']) : parent::noDataDefaultValue();
82
    }
83
84
    /**
85
     * Returns the total count of shares for $url via Delicious.
@@ 133-142 (lines=10) @@
130
     * @param   url   string     The URL to check.
131
     * @return        integer    Returns the total count of URL shares.
132
     */
133
    public static function getDiggShares($url = false)
134
    {
135
        $url     = parent::getUrl($url);
136
        $dataUrl = sprintf(Config\Services::DIGG_INFO_URL, urlencode($url));
137
138
        $jsonData = parent::_getPage($dataUrl);
139
        $phpArray = Helper\Json::decode(substr($jsonData, 2, -2), true);
140
141
        return isset($phpArray['diggs']) ? intval($phpArray['diggs']) : parent::noDataDefaultValue();
142
    }
143
144
    /**
145
     * Returns the total count of shares for $url via LinkedIn.
@@ 151-160 (lines=10) @@
148
     * @param   url   string     The URL to check.
149
     * @return        integer    Returns the total count of URL shares.
150
     */
151
    public static function getLinkedInShares($url = false)
152
    {
153
        $url     = parent::getUrl($url);
154
        $dataUrl = sprintf(Config\Services::LINKEDIN_INFO_URL, urlencode($url));
155
156
        $jsonData = parent::_getPage($dataUrl);
157
        $phpArray = Helper\Json::decode(substr($jsonData, 2, -2), true);
158
159
        return isset($phpArray['count']) ? intval($phpArray['count']) : parent::noDataDefaultValue();
160
    }
161
162
    /**
163
     * Returns the total count of shares for $url via Pinterest.
@@ 169-178 (lines=10) @@
166
     * @param   url   string     The URL to check.
167
     * @return        integer    Returns the total count of URL shares.
168
     */
169
    public static function getPinterestShares($url = false)
170
    {
171
        $url     = parent::getUrl($url);
172
        $dataUrl = sprintf(Config\Services::PINTEREST_INFO_URL, urlencode($url));
173
174
        $jsonData = parent::_getPage($dataUrl);
175
        $phpArray = Helper\Json::decode(substr($jsonData, 2, -1), true);
176
177
        return isset($phpArray['count']) ? intval($phpArray['count']) : parent::noDataDefaultValue();
178
    }
179
180
    /**
181
     * Returns the total count of shares for $url via StumpleUpon.