NewObject::toString()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 0
dl 0
loc 8
rs 10
c 0
b 0
f 0
1
<?php
2
declare(strict_types=1);
3
4
namespace DependencyAnalyzer\DependencyGraph\DependencyTypes;
5
6
use DependencyAnalyzer\DependencyGraph;
7
8
class NewObject extends Base
9
{
10
    /**
11
     * @var string
12
     */
13
    private $caller;
14
15
    public function __construct(string $caller = null)
16
    {
17
        $this->caller = $caller;
18
    }
19
20
    public function getCaller(): ?string
21
    {
22
        return $this->caller;
23
    }
24
25
    public function getType(): string
26
    {
27
        return DependencyGraph::TYPE_NEW;
28
    }
29
30
    public function isEqual(Base $that): bool
31
    {
32
        return (
33
            $that instanceof self &&
34
            $this->getCaller() === $that->getCaller()
35
        );
36
    }
37
38
    public function toString(): string
39
    {
40
        $ret = $this->getType();
41
        if ($this->getCaller()) {
42
            $ret .= ":{$this->getCaller()}";
43
        }
44
45
        return $ret;
46
    }
47
}
48