ErrorException::getBacktrace()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * @author Todd Burry <[email protected]>
4
 * @copyright 2009-2014 Vanilla Forums Inc.
5
 * @license MIT
6
 */
7
8
namespace Garden\Exception;
9
10
/**
11
 * An exception for php errors that also includes the error context and a backtrace.
12
 */
13
class ErrorException extends \ErrorException {
14
    protected $context;
15
16
    protected $backtrace;
17
18
    /**
19
     * Initialize an instance of the {@link ErrorException} class.
20
     *
21
     * @param string $message The error message.
22
     * @param int $number The error number.
23
     * @param int $filename The file where the error occurred.
24
     * @param string $line The line number in the file.
25
     * @param int $context The currently defined variables when the error occured.
26
     * @param array $backtrace A debug backtrace from when the error occurred.
27
     */
28 5
    public function __construct($message, $number, $filename, $line, $context, $backtrace = []) {
29 5
        parent::__construct($message, $number, 0, $filename, $line);
30 5
        $this->context = $context;
31 5
        $this->backtrace = $backtrace;
32 5
    }
33
34
    /**
35
     * Get the debug backtrace from the error.
36
     *
37
     * @return array Returns the backtrace.
38
     */
39
    public function getBacktrace() {
40
        return $this->backtrace;
41
    }
42
43
    /**
44
     * Get the error context.
45
     *
46
     * @return int
47
     */
48
    public function getContext() {
49
        return $this->context;
50
    }
51
}