TelegramException::getDescription()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Zanzara\Telegram\Type\Response;
6
7
use Exception;
8
9
/**
10
 *
11
 */
12
class TelegramException extends Exception implements \JsonSerializable
13
{
14
15
    /**
16
     * @var int|null
17
     */
18
    private $errorCode;
19
20
    /**
21
     * @var string|null
22
     */
23
    private $description;
24
25
    /**
26
     * @return int|null
27
     */
28
    public function getErrorCode(): ?int
29
    {
30
        return $this->errorCode;
31
    }
32
33
    /**
34
     * @param int|null $errorCode
35
     */
36
    public function setErrorCode(?int $errorCode): void
37
    {
38
        $this->errorCode = $errorCode;
39
    }
40
41
    /**
42
     * @return string|null
43
     */
44
    public function getDescription(): ?string
45
    {
46
        return $this->description;
47
    }
48
49
    /**
50
     * @param string|null $description
51
     */
52
    public function setDescription(?string $description): void
53
    {
54
        $this->description = $description;
55
    }
56
57
    /**
58
     * @inheritDoc
59
     */
60
    public function jsonSerialize()
61
    {
62
        return [
63
            'error_code' => $this->errorCode,
64
            'description' => $this->description
65
        ];
66
    }
67
68
    public function __toString()
69
    {
70
        return json_encode($this);
71
    }
72
73
}
74