Test Setup Failed
Push — master ( 9fa851...19bcef )
by
unknown
15:59 queued 13:07
created

PaystackException::setContext()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
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 5
rs 10
cc 1
nc 1
nop 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