Completed
Push — master ( 356849...08f0e0 )
by Changwan
05:29
created

CannotCallMethodException   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 83.33%

Importance

Changes 0
Metric Value
dl 0
loc 39
ccs 10
cts 12
cp 0.8333
rs 10
c 0
b 0
f 0
wmc 4
lcom 0
cbo 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 2
A getMethodName() 0 4 1
A getClassName() 0 4 1
1
<?php
2
namespace Wandu\Http\Exception;
3
4
use RuntimeException;
5
6
class CannotCallMethodException extends RuntimeException
7
{
8
    /** @var string */
9
    protected $methodName;
10
    
11
    /** @var string */
12
    protected $className;
13
14
    /**
15
     * @param string $methodName
16
     * @param string $className
17
     */
18 8
    public function __construct($methodName, $className = null)
19
    {
20 8
        $this->methodName = $methodName;
21 8
        $this->className = $className;
22 8
        $message = "cannot call {$methodName}";
23 8
        if ($className) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $className of type string|null is loosely compared to true; this is ambiguous if the string can be empty. You might want to explicitly use !== null instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For string values, the empty string '' is a special case, in particular the following results might be unexpected:

''   == false // true
''   == null  // true
'ab' == false // false
'ab' == null  // false

// It is often better to use strict comparison
'' === false // false
'' === null  // false
Loading history...
24 8
            $message .= " in {$className}";
25
        }
26 8
        parent::__construct($message);
27 8
    }
28
29
    /**
30
     * @return string
31
     */
32 8
    public function getMethodName()
33
    {
34 8
        return $this->methodName;
35
    }
36
37
    /**
38
     * @return string
39
     */
40
    public function getClassName()
41
    {
42
        return $this->className;
43
    }
44
}
45