Passed
Push — master ( abe9d4...f9c79d )
by Vladimir
04:18
created

LinkedIn::buildLink()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 7
nc 2
nop 0
dl 0
loc 12
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/**
3
 * @link https://github.com/yiimaker/yii2-social-share
4
 * @copyright Copyright (c) 2017 Yii Maker
5
 * @license BSD 3-Clause License
6
 */
7
8
namespace ymaker\social\share\drivers;
9
10
use ymaker\social\share\base\DriverAbstract;
11
12
/**
13
 * DriverAbstract for LinkedIn.
14
 * @link https://linkedin.com
15
 *
16
 * @property bool|string $siteName
17
 *
18
 * @author Vladimir Kuprienko <[email protected]>
19
 * @since 1.0
20
 */
21
class LinkedIn extends DriverAbstract
22
{
23
    /**
24
     * @var bool|string
25
     */
26
    public $siteName = false;
27
28
29
    /**
30
     * @inheritdoc
31
     */
32
    protected function processShareData()
33
    {
34
        $this->url = static::encodeData($this->url);
35
        $this->title = static::encodeData($this->title);
36
        $this->description = static::encodeData($this->description);
37
38
        if (is_string($this->siteName)) {
39
            $this->appendToData('siteName', $this->siteName);
40
        }
41
    }
42
43
    /**
44
     * @inheritdoc
45
     */
46
    protected function buildLink()
47
    {
48
        $link = 'https://www.linkedin.com/shareArticle?mini=true'
49
                    . '&url={url}'
50
                    . '&title={title}'
51
                    . '&summary={description}';
52
53
        if ($this->siteName) {
54
            $this->addUrlParam($link, 'source', '{siteName}');
55
        }
56
57
        return $link;
58
    }
59
}
60