LinkedIn::getName()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 4
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 4
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of the SocialShare package.
5
 *
6
 * (c) Kévin Dunglas <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace SocialShare\Provider;
13
14
/**
15
 * LinkedIn.
16
 *
17
 * @author Morrison Laju <[email protected]>
18
 */
19 View Code Duplication
class LinkedIn implements ProviderInterface
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
20
{
21
    const NAME = 'linkedin';
22
    const SHARE_URL = 'https://www.linkedin.com/shareArticle?%s';
23
    const API_URL = 'https://www.linkedin.com/countserv/count/share?url=%s&format=json';
24
25
    /**
26
     * {@inheritdoc}
27
     */
28
    public function getName()
29
    {
30
        return self::NAME;
31
    }
32
33
    /**
34
     * Gets the share link for the URL.
35
     *
36
     * @param array  $options This provider supports the following options:<pre>
37
     *                        title: the title
38
     *                        summary: the summary
39
     *                        source: the source
40
     *                        </pre>
41
     * @param string $url
42
     * @param array  $options
43
     *
44
     * @return string
45
     */
46
    public function getLink($url, array $options = array())
47
    {
48
        $options['mini'] = 'true';
49
        $options['url'] = $url;
50
51
        return sprintf(self::SHARE_URL, http_build_query($options, null, '&'));
52
    }
53
54
    /**
55
     * {@inheritdoc}
56
     */
57
    public function getShares($url)
58
    {
59
        $data = json_decode(file_get_contents(sprintf(self::API_URL, urlencode($url))));
60
61
        return intval($data->count);
62
    }
63
}
64