Completed
Push — master ( 595e4b...944328 )
by Changwan
07:08
created

NotAllowedMethodException   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 39
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\Config\Exception;
3
4
use RuntimeException;
5
6
class NotAllowedMethodException 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
    public function __construct($methodName, $className = null)
19
    {
20
        $this->methodName = $methodName;
21
        $this->className = $className;
22
        $message = "cannot call {$methodName}";
23
        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
            $message .= " in {$className}";
25
        }
26
        parent::__construct($message);
27
    }
28
29
    /**
30
     * @return string
31
     */
32
    public function getMethodName()
33
    {
34
        return $this->methodName;
35
    }
36
37
    /**
38
     * @return string
39
     */
40
    public function getClassName()
41
    {
42
        return $this->className;
43
    }
44
}
45