Test Setup Failed
Pull Request — master (#9)
by
unknown
13:59
created

PaystackConnectionException::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
nc 1
nop 4
1
<?php
2
3
namespace Iamolayemi\Paystack\Exceptions;
4
5
use Exception;
6
7
/**
8
 * Exception thrown when there's a connection issue with Paystack API.
9
 */
10
class PaystackConnectionException extends PaystackException
11
{
12
    protected ?string $url = null;
13
14
    public function __construct(string $message = '', int $code = 0, ?string $url = null, ?Exception $previous = null)
15
    {
16
        parent::__construct($message, $code, $previous);
17
        $this->url = $url;
18
    }
19
20
    public function getUrl(): ?string
21
    {
22
        return $this->url;
23
    }
24
25
    public static function connectionFailed(string $url, ?Exception $previous = null): self
26
    {
27
        return new self(
28
            'Failed to connect to Paystack API',
29
            0,
30
            $url,
31
            $previous
32
        );
33
    }
34
}
35