Completed
Push — master ( 1092e2...11ab51 )
by Alexander
06:55
created

ApiException::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 4
rs 10
1
<?php
2
3
namespace Flugg\Responder\Exceptions\Http;
4
5
use Symfony\Component\HttpKernel\Exception\HttpException;
6
7
/**
8
 * An abstract base exception used for any API related exceptions. All exceptions thrown
9
 * that extends this class will automatically be converted to JSON responses if using
10
 * the \Flugg\Responder\Traits\HandlesApiErrors trait in your exception handler.
11
 *
12
 * @package flugger/laravel-responder
13
 * @author  Alexander Tømmerås <[email protected]>
14
 * @license The MIT License
15
 */
16
abstract class ApiException extends HttpException
17
{
18
    /**
19
     * The HTTP status code.
20
     *
21
     * @var int
22
     */
23
    protected $statusCode = 500;
24
25
    /**
26
     * The error code.
27
     *
28
     * @var string
29
     */
30
    protected $errorCode = 'error_occurred';
31
32
    /**
33
     * Constructor.
34
     *
35
     * @param mixed $message
36
     */
37
    public function __construct($message = null)
38
    {
39
        parent::__construct($this->statusCode, $message);
40
    }
41
42
    /**
43
     * Get the HTTP status code,
44
     *
45
     * @return int
46
     */
47
    public function getStatusCode()
48
    {
49
        return $this->statusCode;
50
    }
51
52
    /**
53
     * Get the error code.
54
     *
55
     * @return string
56
     */
57
    public function getErrorCode()
58
    {
59
        return $this->errorCode;
60
    }
61
62
    /**
63
     * Get the error data.
64
     *
65
     * @return array|null
66
     */
67
    public function getData()
68
    {
69
        return null;
70
    }
71
}