Passed
Push — master ( 50f068...bac002 )
by Satoshi
02:14
created

ResolveDependencyException::getNodeType()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
declare(strict_types=1);
3
4
namespace DependencyAnalyzer\Exceptions;
5
6
use PhpParser\Node;
7
8
class ResolveDependencyException extends RuntimeException
9
{
10
    /**
11
     * @var Node
12
     */
13
    private $node;
14
15
    public function __construct(Node $node, $message = '', $code = 0, \Throwable $previous = null)
16
    {
17
        parent::__construct($message, $code, $previous);
18
        $this->node = $node;
19
    }
20
21
    public function getNodeLine()
22
    {
23
        return $this->node->getLine();
24
    }
25
26
    public function getNodeType()
27
    {
28
        return $this->node->getType();
29
    }
30
31
    public function __toString(): string
32
    {
33
        return parent::__toString() . ' ' . $this->nodeToString();
34
    }
35
36
    protected function nodeToString(): string
37
    {
38
        return "type: {$this->getNodeType()}, line: {$this->getNodeLine()}";
39
    }
40
}
41