Completed
Pull Request — master (#20)
by
unknown
01:26
created

Facebook::shareCountRequestMultiple()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 12
rs 9.4285
cc 1
eloc 7
nc 1
nop 0
1
<?php
2
3
namespace SocialLinks\Providers;
4
5
class Facebook extends ProviderBase implements ProviderInterface
6
{
7
    /**
8
     * {@inheritdoc}
9
     */
10
    public function shareUrl()
11
    {
12
        return $this->buildUrl(
13
            'https://www.facebook.com/sharer/sharer.php',
14
            array(
15
                'url' => 'u',
16
                'title' => 't',
17
            ),
18
            array(
19
                'display' => 'popup',
20
                'redirect_uri' => 'http://www.facebook.com',
21
            )
22
        );
23
    }
24
25
    /**
26
     * {@inheritdoc}
27
     */
28
    public function shareCountRequest()
29
    {
30
        return static::request(
31
            $this->buildUrl(
32
                'https://graph.facebook.com/',
33
                array(),
34
                array(
35
                    'id' => $this->page->getUrl(),
36
                )
37
            )
38
        );
39
    }
40
41
    /**
42
     * {@inheritdoc}
43
     */
44
    public function shareCount($response)
45
    {
46
        $count = self::jsonResponse($response);
47
48
        return isset($count['share']['share_count']) ? intval($count['share']['share_count']) : 0;
49
    }
50
51
    /**
52
     * {@inheritdoc}
53
     */
54
    public function shareCountRequestMultiple()
55
    {
56
        return static::request(
57
            $this->buildUrl(
58
                'https://graph.facebook.com/',
59
                array(),
60
                array(
61
                    'ids' => implode(',', $this->page->getUrls())
62
                )
63
            )
64
        );
65
    }
66
67
    /**
68
     * {@inheritdoc}
69
     */
70
    public function shareCountMultiple($response)
71
    {
72
        $count_array = self::jsonResponse($response);
73
74
        return array_map(function ($count) {
75
            return isset($count['share']['share_count']) ? intval($count['share']['share_count']) : 0;
76
        }, $count_array);
77
    }
78
}
79