RestSystemException::setHttpStatusCode()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 4
Ratio 100 %

Importance

Changes 0
Metric Value
dl 4
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace Ntb\RestAPI;
4
5
/**
6
 * The system exception can be used for showing a system error like a missing file or a broken connection.
7
 * @author Christian Blank <[email protected]>
8
 */
9 View Code Duplication
class RestSystemException extends \Exception {
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
10
    /*
11
     * @var int - override the default http status code if needed
12
     */
13
    protected $httpStatusCode;
14
15
    /**
16
     * RestSystemException constructor.
17
     * @param string $message the error message
18
     * @param int $errorCode the error code of the api
19
     * @param int $httpStatusCode the http status code in the response; Default=500
20
     */
21
    public function __construct($message, $errorCode, $httpStatusCode = 500) {
22
        parent::__construct($message, $errorCode);
23
        $this->httpStatusCode = $httpStatusCode;
24
    }
25
26
27
    /**
28
     * @return int
29
     */
30
    public function getHttpStatusCode() {
31
        return $this->httpStatusCode;
32
    }
33
34
    /**
35
     * @param int $httpStatusCode
36
     * @return $this
37
     */
38
    public function setHttpStatusCode($httpStatusCode) {
39
        $this->httpStatusCode = $httpStatusCode;
40
        return $this;
41
    }
42
43
}
44