MethodNotFoundException   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 69
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 0
dl 0
loc 69
c 0
b 0
f 0
ccs 14
cts 14
cp 1
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A generateMessage() 0 4 1
A getObject() 0 4 1
A getName() 0 4 1
A getArguments() 0 4 1
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: horat1us
5
 * Date: 5/8/17
6
 * Time: 4:46 PM
7
 */
8
9
namespace Horat1us\MethodInjection;
10
11
12
use Throwable;
13
14
/**
15
 * Class MethodNotFoundException
16
 * @package Horat1us\MethodInjection
17
 */
18
class MethodNotFoundException extends \Exception
19
{
20
    /**
21
     * List of arguments, which was used to call method
22
     *
23
     * @var array
24
     */
25
    protected $arguments;
26
27
    /**
28
     * Injected method name
29
     *
30
     * @var string
31
     */
32
    protected $name;
33
34
    /**
35
     * Object with not-found injected method
36
     *
37
     * @var object
38
     */
39
    protected $object;
40
41
    /**
42
     * MethodNotFoundException constructor.
43
     * @param $object
44
     * @param string $name
45
     * @param array $arguments
46
     */
47 2
    public function __construct($object, string $name, array $arguments = [])
48
    {
49 2
        $this->name = $name;
50 2
        $this->object = $object;
51 2
        $this->arguments = $arguments;
52 2
        parent::__construct($this->generateMessage());
53 2
    }
54
55
    /**
56
     * @return string
57
     */
58 2
    protected function generateMessage()
59
    {
60 2
        return "Injected method {$this->name} not found in " . get_class($this->object);
61
    }
62
63
    /**
64
     * @return object
65
     */
66 1
    public function getObject()
67
    {
68 1
        return $this->object;
69
    }
70
71
    /**
72
     * @return string
73
     */
74 1
    public function getName(): string
75
    {
76 1
        return $this->name;
77
    }
78
79
    /**
80
     * @return array
81
     */
82 1
    public function getArguments(): array
83
    {
84 1
        return $this->arguments;
85
    }
86
}
87