Completed
Push — master ( 33767c...d0bf09 )
by Tim
15s queued 12s
created

Error::getException()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 0
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * AppserverIo\Appserver\ServletEngine\Utils\Error
5
 *
6
 * NOTICE OF LICENSE
7
 *
8
 * This source file is subject to the Open Software License (OSL 3.0)
9
 * that is available through the world-wide-web at this URL:
10
 * http://opensource.org/licenses/osl-3.0.php
11
 *
12
 * PHP version 5
13
 *
14
 * @author    Tim Wagner <[email protected]>
15
 * @copyright 2015 TechDivision GmbH <[email protected]>
16
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
 * @link      https://github.com/appserver-io/appserver
18
 * @link      http://www.appserver.io
19
 */
20
21
namespace AppserverIo\Appserver\ServletEngine\Utils;
22
23
/**
24
 * Wrapper for an error triggered by PHP's default error handling.
25
 *
26
 * @author    Tim Wagner <[email protected]>
27
 * @copyright 2015 TechDivision GmbH <[email protected]>
28
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
29
 * @link      https://github.com/appserver-io/appserver
30
 * @link      http://www.appserver.io
31
 */
32
class Error extends \AppserverIo\Appserver\Core\Utilities\Error implements ErrorInterface
33
{
34
35
    /**
36
     * The HTTP status code that has to be send back with the response.
37
     *
38
     * @var integer
39
     */
40
    protected $statusCode;
41
42
    /**
43
     * The original exception instance.
44
     *
45
     * @var \Exception|null
46
     */
47
    protected $exception;
48
49
    /**
50
     * Initializes the error with the passed values.
51
     *
52
     * @param integer         $type       The error type
53
     * @param string          $message    The error message
54
     * @param string          $file       The name of the file where the error has been triggered
55
     * @param integer         $line       The line in the file where the error has been triggered
56
     * @param integer         $statusCode The HTTP status code that has to be send back with the response
57
     * @param \Exception|null $exception  The original exception instance
58
     */
59
    public function __construct($type, $message, $file, $line, $statusCode = 0, $exception = null)
60
    {
61
62
        // invoke the parent method
63
        parent::__construct($type, $message, $file, $line);
64
65
        // initialize the status code
66
        $this->statusCode = $statusCode;
67
68
        // initialize the exception
69
        $this->exception = $exception;
70
    }
71
72
    /**
73
     * Return's the HTTP status code that has to be send back with the response.
74
     *
75
     * @return integer The HTTP status code
76
     */
77
    public function getStatusCode()
78
    {
79
        return $this->statusCode;
80
    }
81
82
    /**
83
     * Returns the exception instance.
84
     *
85
     * @return \Exception|null
86
     */
87
    public function getException()
88
    {
89
        return $this->exception;
90
    }
91
}
92