ErrorException   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 55.56%

Importance

Changes 0
Metric Value
dl 0
loc 39
ccs 5
cts 9
cp 0.5556
rs 10
c 0
b 0
f 0
wmc 3
lcom 0
cbo 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getBacktrace() 0 3 1
A getContext() 0 3 1
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
}