Completed
Push — master ( 511324...c26f0f )
by Konstantinos
08:12
created

HTTPException::getHeaders()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
/**
3
 * This file contains an exception class
4
 *
5
 * @package    BZiON\Exceptions
6
 * @license    https://github.com/allejo/bzion/blob/master/LICENSE.md GNU General Public License Version 3
7
 */
8
9
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
10
11
/**
12
 * An Exception with an HTTP error code, the message of which is visible to the user
13
 * @package BZiON\Exceptions
14
 */
15
abstract class HTTPException extends Exception implements HttpExceptionInterface
16
{
17
    /**
18
     * The exception's message
19
     * @var null|string
20
     */
21
    protected $message = null;
22
23
    /**
24
     * Construct new Exception
25
     * @param null|string $message  The Exception's message
26
     *                              (null for the default one)
27
     * @param int         $code     The Exception's code
28
     * @param Exception   $previous The previous exception
29
     */
30 1
    public function __construct(
31
        $message = null,
32
        $code = 0,
33
        Exception $previous = null
34
    ) {
35 1
        if ($message === null) {
36
            // Workaround for HHVM that doesn't support shadowing of properties
37
            // for Exceptions
38
            $message = $this->message;
39
        }
40
41 1
        return parent::__construct($message, $code, $previous);
0 ignored issues
show
Bug introduced by
Constructors do not have meaningful return values, anything that is returned from here is discarded. Are you sure this is correct?
Loading history...
42
    }
43
44
    /**
45
     * The HTTP error code that the response should include
46
     * @return int
47
     */
48
    public function getStatusCode()
49
    {
50
        return 500;
51
    }
52
53
    /**
54
     * Headers to be included in the response
55
     * @return array
56
     */
57 1
    public function getHeaders()
58
    {
59 1
        return array();
60
    }
61
}
62