Telegram   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

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

2 Methods

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