LinkedIn   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 14
c 1
b 0
f 0
dl 0
loc 36
rs 10

2 Methods

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