/** * setParent() and getParent() should set and get the element's parent */ public function testSetGetParent() { $parent = new Group(); $element = new Element(); $element->setParent($parent); $expected = $parent; $actual = $element->getParent(); $this->assertSame($expected, $actual); return; }
public static function isLastChild($value, Element $element, $index) { return $index !== null && $index === $element->getParent()->getChildCount() - 1; }
/** * Inserts this element before $element * * @param Jstewmc\Rtf\Element $element the element to insert before * @return self * @throws BadMethodCallException if $element doesn't have a parent * @throws BadMethodCallException if $element's parent doesn't have children * @throws BadMethodCallException if $element is not a child of its parent * @since 0.1.0 */ public function insertBefore(Element $element) { // if $element has an index if (false !== ($index = $element->getIndex())) { $element->getParent()->insertChild($this, $index); } return $this; }