| 1 | <?php |
||
| 7 | class Node |
||
| 8 | { |
||
| 9 | /** |
||
| 10 | * Name of the node |
||
| 11 | * |
||
| 12 | * @var string |
||
| 13 | **/ |
||
| 14 | private $name; |
||
| 15 | |||
| 16 | /** |
||
| 17 | * Parent node |
||
| 18 | * |
||
| 19 | * @var Node |
||
| 20 | **/ |
||
| 21 | private $parent; |
||
| 22 | |||
| 23 | /** |
||
| 24 | * Constructor |
||
| 25 | * |
||
| 26 | * @param string $name |
||
| 27 | * @return void |
||
|
|
|||
| 28 | **/ |
||
| 29 | public function __construct($name) |
||
| 33 | |||
| 34 | /** |
||
| 35 | * Get the name of the node |
||
| 36 | * |
||
| 37 | * @return string |
||
| 38 | */ |
||
| 39 | public function getName() |
||
| 43 | |||
| 44 | /** |
||
| 45 | * Set the name of the node |
||
| 46 | * |
||
| 47 | * @param string $name |
||
| 48 | * @return Node |
||
| 49 | */ |
||
| 50 | public function setName($name) |
||
| 56 | |||
| 57 | /** |
||
| 58 | * Get the name including that of the parent's |
||
| 59 | * |
||
| 60 | * @param string $separator |
||
| 61 | * @return string |
||
| 62 | **/ |
||
| 63 | public function getFullName($separator = DIRECTORY_SEPARATOR) |
||
| 73 | |||
| 74 | /** |
||
| 75 | * Get the parent node |
||
| 76 | * |
||
| 77 | * @return Node |
||
| 78 | */ |
||
| 79 | public function getParent() |
||
| 83 | |||
| 84 | /** |
||
| 85 | * Set the parent node |
||
| 86 | * |
||
| 87 | * @param Node $parent |
||
| 88 | * @return Node |
||
| 89 | */ |
||
| 90 | public function setParent(Node $parent) |
||
| 96 | |||
| 97 | /** |
||
| 98 | * Does this node have a parent? |
||
| 99 | * |
||
| 100 | * @return bool |
||
| 101 | **/ |
||
| 102 | public function hasParent() |
||
| 106 | } |
||
| 107 |
Adding a
@returnannotation to a constructor is not recommended, since a constructor does not have a meaningful return value.Please refer to the PHP core documentation on constructors.