Completed
Push — master ( b7d6fa...54f51b )
by Ryuichi
02:48
created

DelegateException   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 66.67%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 49
ccs 8
cts 12
cp 0.6667
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A isHandled() 0 4 1
A enableHandled() 0 4 1
A getOriginException() 0 4 1
1
<?php
2
namespace WebStream\Exception;
3
4
/**
5
 * ApplicationException
6
 * @author Ryuichi TANAKA.
7
 * @since 2014/05/05
8
 * @version 0.4
9
 */
10
class DelegateException extends ApplicationException
11
{
12
    /**
13
     * @var bool ハンドリング可否
14
     */
15
    private $isHandled;
16
17
    /**
18
     * @var \Exception 例外オブジェクト
19
     */
20
    private $originException;
21
22
    /**
23
     * constructor
24
     * @param \Exception 例外オブジェクト
25
     */
26 4
    public function __construct(\Exception $originException)
27
    {
28 4
        parent::__construct($originException->getMessage(), 500, $originException);
0 ignored issues
show
Documentation introduced by
$originException is of type object<Exception>, but the function expects a object<WebStream\Exception\Exception>|null.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
29 4
        $this->originException = $originException;
30 4
        $this->isHandled = false;
31 4
    }
32
33
    /**
34
     * オリジナルの例外を返却する
35
     * @return \Exception 例外オブジェクト
36
     */
37
    public function getOriginException()
38
    {
39
        return $this->originException;
40
    }
41
42
    /**
43
     * ハンドリング可否を返却する
44
     * @return bool ハンドリング可否
45
     */
46
    public function isHandled()
47
    {
48
        return $this->isHandled;
49
    }
50
51
    /**
52
     * ハンドリングを許可する
53
     */
54 4
    public function enableHandled()
55
    {
56 4
        $this->isHandled = true;
57 4
    }
58
}
59