JiraBaseException::__construct()   A
last analyzed

Complexity

Conditions 3
Paths 4

Size

Total Lines 11
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 3

Importance

Changes 0
Metric Value
cc 3
eloc 5
nc 4
nop 3
dl 0
loc 11
ccs 6
cts 6
cp 1
crap 3
rs 10
c 0
b 0
f 0
1
<?php
2
declare(strict_types=1);
3
4
/**
5
 * Exception
6
 */
7
8
namespace Fr3nch13\Jira\Exception;
9
10
use Cake\Core\Exception\CakeException;
11
12
/**
13
 * Issue Submission Exception
14
 *
15
 * The generic Jira specific exception.
16
 */
17
class JiraBaseException extends CakeException
18
{
19
    /**
20
     * @var int Throw a 500 when something goes wrong.
21
     */
22
    protected $_defaultCode = 500;
23
24
    /**
25
     * Constructor.
26
     *
27
     * Allows you to create exceptions that are treated as framework errors and disabled
28
     * when debug mode is off.
29
     *
30
     * @param string|array<int, string> $message Either the string of the error message, or an array of attributes
31
     *   that are made available in the view, and sprintf()'d into Exception::$_messageTemplate
32
     * @param int|null $code The code of the error, is also the HTTP status code for the error.
33
     * @param \Exception|null $previous the previous exception.
34
     */
35 36
    public function __construct($message = '', $code = null, $previous = null)
36
    {
37 36
        if (!$this->_messageTemplate) {
38 2
            $this->_messageTemplate = __('Jira Error(s): %s');
39
        }
40
41 36
        if (is_string($message)) {
42 36
            $message = [0 => $message];
43
        }
44
45 36
        parent::__construct($message, $code, $previous);
46
    }
47
}
48