MontealegreLuis /
phuml
| 1 | <?php declare(strict_types=1); |
||
| 2 | /** |
||
| 3 | * This source file is subject to the license that is bundled with this package in the file LICENSE. |
||
| 4 | */ |
||
| 5 | |||
| 6 | namespace PhUml\Code; |
||
| 7 | |||
| 8 | use PhUml\Code\Methods\Method; |
||
| 9 | use PhUml\Code\Properties\Constant; |
||
| 10 | use PhUml\Code\Properties\HasConstants; |
||
| 11 | use PhUml\Code\Properties\WithConstants; |
||
| 12 | |||
| 13 | /** |
||
| 14 | * It represents an interface definition |
||
| 15 | */ |
||
| 16 | final class InterfaceDefinition extends Definition implements HasConstants |
||
| 17 | { |
||
| 18 | use WithConstants; |
||
| 19 | |||
| 20 | /** @var Name[] */ |
||
| 21 | private readonly array $parents; |
||
| 22 | |||
| 23 | /** |
||
| 24 | * @param Method[] $methods |
||
| 25 | * @param Constant[] $constants |
||
| 26 | * @param Name[] $parents |
||
| 27 | */ |
||
| 28 | 52 | public function __construct( |
|
| 29 | Name $name, |
||
| 30 | array $methods = [], |
||
| 31 | array $constants = [], |
||
| 32 | array $parents = [] |
||
| 33 | ) { |
||
| 34 | 52 | parent::__construct($name, $methods); |
|
| 35 | 52 | $this->constants = $constants; |
|
| 36 | 52 | $this->parents = $parents; |
|
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 37 | } |
||
| 38 | |||
| 39 | /** |
||
| 40 | * It is used by the `InterfaceGraphBuilder` to create the edge to represent inheritance |
||
| 41 | * |
||
| 42 | * @return Name[] |
||
| 43 | * @see \PhUml\Graphviz\Builders\InterfaceGraphBuilder::extractFrom() for more details |
||
| 44 | */ |
||
| 45 | 25 | public function parents(): array |
|
| 46 | { |
||
| 47 | 25 | return $this->parents; |
|
| 48 | } |
||
| 49 | |||
| 50 | /** |
||
| 51 | * It is used by the `InterfaceGraphBuilder` to determine if an inheritance association should be |
||
| 52 | * created |
||
| 53 | * |
||
| 54 | * @see \PhUml\Graphviz\Builders\InterfaceGraphBuilder::extractFrom() for more details |
||
| 55 | */ |
||
| 56 | 1 | public function hasParent(): bool |
|
| 57 | { |
||
| 58 | 1 | return $this->parents !== []; |
|
| 59 | } |
||
| 60 | |||
| 61 | /** |
||
| 62 | * This method is used when the commands are called with the option `hide-empty-blocks` |
||
| 63 | * |
||
| 64 | * It only counts the constants of an interface, since interfaces are not allowed to have |
||
| 65 | * properties |
||
| 66 | * |
||
| 67 | * @see Definition::hasProperties() for more details |
||
| 68 | */ |
||
| 69 | 14 | public function hasProperties(): bool |
|
| 70 | { |
||
| 71 | 14 | return $this->constants !== []; |
|
| 72 | } |
||
| 73 | } |
||
| 74 |