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

ExceptionWithContext::getContext()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
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