Completed
Push — master ( cc396e...a9e063 )
by Chad
9s
created

ExceptionWithContext   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 5
dl 0
loc 27
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getContext() 0 3 1
A __construct() 0 4 1
1
<?php
2
3
namespace TraderInteractive\Exceptions;
4
5
use Throwable;
6
7
/**
8
 * Exception with variable context.
9
 */
10
class ExceptionWithContext extends \Exception
11
{
12
    /**
13
     * @var array
14
     */
15
    private $context;
16
17
    /**
18
     * Construct a new instance of the exception.
19
     *
20
     * @param string $message The exception message.
21
     * @param array  $context Any local context information.
22
     */
23
    public function __construct(string $message, array $context = [], int $code = 0, Throwable $previous = null)
24
    {
25
        parent::__construct($message, $code, $previous);
26
        $this->context = $context;
27
    }
28
29
    /**
30
     * Returns the specified context array associated with this exception.
31
     *
32
     * @return array
33
     */
34
    public function getContext() : array
35
    {
36
        return $this->context;
37
    }
38
}
39