NewObject::getType()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 1
c 1
b 0
f 1
nc 1
nop 0
dl 0
loc 3
rs 10
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