Merge branch '3.1' into 5.2
[GitHub/WoltLab/WCF.git] / wcfsetup / install / files / lib / data / IObjectTreeNode.class.php
1 <?php
2 namespace wcf\data;
3
4 /**
5 * Every node of a database object tree has to implement this interface.
6 *
7 * @author Matthias Schmidt
8 * @copyright 2001-2019 WoltLab GmbH
9 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
10 * @package WoltLabSuite\Core\Data
11 * @since 5.2
12 */
13 interface IObjectTreeNode extends \Countable, IIDObject, \RecursiveIterator {
14 /**
15 * Adds the given node as child node and sets the child node's parent node to this node.
16 *
17 * @param IObjectTreeNode $child added child node
18 * @throws \InvalidArgumentException if given object is no (deocrated) instance of this class
19 */
20 public function addChild(IObjectTreeNode $child);
21
22 /**
23 * Returns the depth of the node within the tree.
24 *
25 * The minimum depth is `1`.
26 *
27 * @return integer
28 */
29 public function getDepth();
30
31 /**
32 * Returns the number of open parent nodes.
33 *
34 * @return integer
35 */
36 public function getOpenParentNodes();
37
38 /**
39 * Retruns the parent node of this node.
40 *
41 * @return static parent node
42 */
43 public function getParentNode();
44
45 /**
46 * Returns `true` if this node is the last sibling and `false` otherwise.
47 *
48 * @return boolean
49 */
50 public function isLastSibling();
51
52 /**
53 * Sets the parent node of this node.
54 *
55 * @param IObjectTreeNode $parentNode parent node
56 * @throws \InvalidArgumentException if given object is no (deocrated) instance of this class
57 */
58 public function setParentNode(IObjectTreeNode $parentNode);
59 }