SmsSendingFailedException::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
nc 1
nop 4
dl 0
loc 7
rs 10
c 1
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Kafkiansky\SmsRu\Exceptions;
6
7
use Throwable;
8
9
final class SmsSendingFailedException extends \Exception
10
{
11
    /**
12
     * @var int
13
     */
14
    private $statusCode;
15
16
    /**
17
     * @var string|null
18
     */
19
    private $statusText;
20
21
    public function __construct(int $statusCode, string $statusText = null, $code = 0, Throwable $previous = null)
22
    {
23
        $message = \sprintf('sms.ru responded with an error, status text: %s', $statusText ?? '');
24
        $this->statusCode = $statusCode;
25
        $this->statusText = $statusText;
26
27
        parent::__construct($message, $code, $previous);
28
    }
29
30
    /**
31
     * @return int
32
     */
33
    public function getStatusCode(): int
34
    {
35
        return $this->statusCode;
36
    }
37
38
    /**
39
     * @return string|null
40
     */
41
    public function getStatusText(): ?string
42
    {
43
        return $this->statusText;
44
    }
45
}
46