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

PaystackException   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 7
c 1
b 0
f 0
dl 0
loc 34
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setContext() 0 5 1
A getContext() 0 3 1
A __construct() 0 8 1
1
<?php
2
3
namespace Iamolayemi\Paystack\Exceptions;
4
5
use Exception;
6
7
/**
8
 * Base exception class for all Paystack-related exceptions.
9
 */
10
class PaystackException extends Exception
11
{
12
    /** @var array<string, mixed> */
13
    protected array $context = [];
14
15
    /**
16
     * @param  array<string, mixed>  $context
17
     */
18
    public function __construct(
19
        string $message = '',
20
        int $code = 0,
21
        ?Exception $previous = null,
22
        array $context = []
23
    ) {
24
        parent::__construct($message, $code, $previous);
25
        $this->context = $context;
26
    }
27
28
    /**
29
     * @return array<string, mixed>
30
     */
31
    public function getContext(): array
32
    {
33
        return $this->context;
34
    }
35
36
    /**
37
     * @param  array<string, mixed>  $context
38
     */
39
    public function setContext(array $context): self
40
    {
41
        $this->context = $context;
42
43
        return $this;
44
    }
45
}
46