/** * Test footnote collection */ public function testFootnotes() { $footnote1 = new \PhpOffice\PhpWord\Element\Footnote(); $footnote2 = new \PhpOffice\PhpWord\Element\Footnote(); $rId = Footnotes::addElement($footnote1); Footnotes::setElement(1, $footnote2); $this->assertEquals(1, $rId); $this->assertEquals(1, count(Footnotes::getElements())); $this->assertEquals($footnote2, Footnotes::getElement(1)); $this->assertNull(Footnotes::getElement(2)); Footnotes::resetElements(); $this->assertEquals(0, Footnotes::countElements()); }
/** * Add footnote element * * @param mixed $paragraphStyle * @return Footnote */ public function addFootnote($paragraphStyle = null) { $this->checkValidity('footnote'); $footnote = new Footnote($paragraphStyle); $rId = Footnotes::addElement($footnote); $footnote->setDocPart('footnote', $this->getDocPartId()); $footnote->setRelationId($rId); $this->addElement($footnote); return $footnote; }