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

Telegram   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 31
rs 10
c 0
b 0
f 0
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A processShareData() 0 5 2
A buildLink() 0 9 2
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 Telegram messenger.
14
 * @link https://telegram.org
15
 *
16
 * @author Vladimir Kuprienko <[email protected]>
17
 * @since 1.0
18
 */
19
class Telegram extends DriverAbstract
20
{
21
    /**
22
     * @var bool|string
23
     */
24
    public $message = false;
25
26
27
    /**
28
     * @inheritdoc
29
     */
30
    protected function processShareData()
31
    {
32
        $this->url = static::encodeData($this->url);
33
        if (is_string($this->message)) {
34
            $this->appendToData('message', $this->message);
35
        }
36
    }
37
38
    /**
39
     * @inheritdoc
40
     */
41
    protected function buildLink()
42
    {
43
        $link = 'https://telegram.me/share/url?url={url}';
44
45
        if ($this->message) {
46
            $this->addUrlParam($link, 'text', '{message}');
47
        }
48
49
        return $link;
50
    }
51
}
52