1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Padawan\Domain\Scope; |
4
|
|
|
|
5
|
|
|
use Padawan\Domain\Project\FQN; |
6
|
|
|
use Padawan\Domain\Project\Node\Uses; |
7
|
|
|
use Padawan\Domain\Project\Node\ClassData; |
8
|
|
|
use Padawan\Domain\Project\Node\InterfaceData; |
9
|
|
|
|
10
|
|
|
class FileScope extends AbstractScope |
11
|
|
|
{ |
12
|
|
|
private $classes = []; |
13
|
|
|
private $interfaces = []; |
14
|
|
|
/** @var FQCN */ |
15
|
|
|
private $namespace; |
|
|
|
|
16
|
|
|
/** @var Uses */ |
17
|
|
|
private $uses; |
18
|
|
|
|
19
|
|
|
public function __construct(FQN $namespace, Uses $uses = null) |
20
|
|
|
{ |
21
|
|
|
$this->uses = $uses; |
22
|
|
|
} |
23
|
|
|
public function getFQCN() |
24
|
|
|
{ |
25
|
|
|
return $this->uses ? $this->uses->getFQCN() : null; |
26
|
|
|
} |
27
|
|
|
public function getNamespace() |
28
|
|
|
{ |
29
|
|
|
return $this->uses ? $this->uses->getFQCN() : null; |
30
|
|
|
} |
31
|
|
|
public function getUses() |
32
|
|
|
{ |
33
|
|
|
return $this->uses; |
34
|
|
|
} |
35
|
|
|
public function getClasses() |
36
|
|
|
{ |
37
|
|
|
return $this->classes; |
38
|
|
|
} |
39
|
|
|
public function getClass($className) |
40
|
|
|
{ |
41
|
|
|
if (array_key_exists($className, $this->classes)) { |
42
|
|
|
return $this->classes[$className]; |
43
|
|
|
} |
44
|
|
|
} |
45
|
|
|
public function addClass(ClassData $class) |
46
|
|
|
{ |
47
|
|
|
$this->classes[$class->getName()] = $class; |
48
|
|
|
} |
49
|
|
|
public function getInterfaces() |
50
|
|
|
{ |
51
|
|
|
return $this->interfaces; |
52
|
|
|
} |
53
|
|
|
public function getInterface($interfaceName) |
54
|
|
|
{ |
55
|
|
|
if (array_key_exists($interfaceName, $this->interfaces)) { |
56
|
|
|
return $this->interfaces[$interfaceName]; |
57
|
|
|
} |
58
|
|
|
} |
59
|
|
|
public function addInterface(InterfaceData $interface) |
60
|
|
|
{ |
61
|
|
|
$this->interfaces[$interface->getName()] = $interface; |
62
|
|
|
} |
63
|
|
|
} |
64
|
|
|
|
This check marks private properties in classes that are never used. Those properties can be removed.