NewObject   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 12
c 1
b 0
f 1
dl 0
loc 38
rs 10
wmc 7

5 Methods

Rating   Name   Duplication   Size   Complexity  
A isEqual() 0 5 2
A getCaller() 0 3 1
A toString() 0 8 2
A __construct() 0 3 1
A getType() 0 3 1
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