RestSystemException   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 0
dl 35
loc 35
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 4 4 1
A getHttpStatusCode() 3 3 1
A setHttpStatusCode() 4 4 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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