1 | <?php |
||
16 | trait InterfacesPart { |
||
17 | |||
18 | /** @var Set|string[] */ |
||
19 | private $interfaces; |
||
20 | |||
21 | 53 | private function initInterfaces() { |
|
22 | 53 | $this->interfaces = new Set(); |
|
23 | 53 | } |
|
24 | |||
25 | /** |
||
26 | * Adds a use statement with an optional alias |
||
27 | * |
||
28 | * @param string $qualifiedName |
||
29 | * @param null|string $alias |
||
30 | * @return $this |
||
31 | */ |
||
32 | abstract public function addUseStatement($qualifiedName, string $alias = null); |
||
33 | |||
34 | /** |
||
35 | * Removes a use statement |
||
36 | * |
||
37 | * @param string $qualifiedName |
||
38 | * @return $this |
||
39 | */ |
||
40 | abstract public function removeUseStatement(string $qualifiedName); |
||
41 | |||
42 | /** |
||
43 | * Returns the namespace |
||
44 | * |
||
45 | * @return string |
||
46 | */ |
||
47 | abstract public function getNamespace(): ?string; |
||
48 | |||
49 | /** |
||
50 | * Adds an interface. |
||
51 | * |
||
52 | * If the interface is passed as PhpInterface object, |
||
53 | * the interface is also added as use statement. |
||
54 | * |
||
55 | * @param PhpInterface|string $interface interface or qualified name |
||
56 | * @return $this |
||
57 | */ |
||
58 | 8 | public function addInterface($interface) { |
|
71 | |||
72 | /** |
||
73 | * Returns the interfaces names |
||
74 | * |
||
75 | * @return Set|string[] |
||
76 | */ |
||
77 | 5 | public function getInterfaces(): Set { |
|
80 | |||
81 | /** |
||
82 | * @return iterable|PhpInterface[] |
||
83 | */ |
||
84 | public function getPhpInterfaces(): iterable |
||
94 | |||
95 | /** |
||
96 | * Checks whether interfaces exists |
||
97 | * |
||
98 | * @return bool `true` if interfaces are available and `false` if not |
||
99 | */ |
||
100 | 16 | public function hasInterfaces(): bool { |
|
103 | |||
104 | /** |
||
105 | * Checks whether an interface exists |
||
106 | * |
||
107 | * @param PhpInterface|string $interface interface name or instance |
||
108 | * @return bool |
||
109 | */ |
||
110 | 4 | public function hasInterface($interface): bool { |
|
118 | |||
119 | /** |
||
120 | * Removes an interface. |
||
121 | * |
||
122 | * If the interface is passed as PhpInterface object, |
||
123 | * the interface is also remove from the use statements. |
||
124 | * |
||
125 | * @param PhpInterface|string $interface interface or qualified name |
||
126 | * @return $this |
||
127 | */ |
||
128 | 1 | public function removeInterface($interface) { |
|
142 | |||
143 | /** |
||
144 | * Sets a collection of interfaces |
||
145 | * |
||
146 | * @param PhpInterface[] $interfaces |
||
147 | * @return $this |
||
148 | */ |
||
149 | 1 | public function setInterfaces(array $interfaces) { |
|
156 | } |
||
157 |