Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
19 / 19
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
Footer
100.00% covered (success)
100.00%
19 / 19
100.00% covered (success)
100.00%
2 / 2
2
100.00% covered (success)
100.00%
1 / 1
 write
100.00% covered (success)
100.00%
17 / 17
100.00% covered (success)
100.00%
1 / 1
1
 setElement
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2/**
3 * This file is part of PHPWord - A pure PHP library for reading and writing
4 * word processing documents.
5 *
6 * PHPWord is free software distributed under the terms of the GNU Lesser
7 * General Public License version 3 as published by the Free Software Foundation.
8 *
9 * For the full copyright and license information, please read the LICENSE
10 * file that was distributed with this source code. For the full list of
11 * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
12 *
13 * @see         https://github.com/PHPOffice/PHPWord
14 *
15 * @license     http://www.gnu.org/licenses/lgpl.txt LGPL version 3
16 */
17
18namespace PhpOffice\PhpWord\Writer\Word2007\Part;
19
20use PhpOffice\PhpWord\Writer\Word2007\Element\Container;
21
22/**
23 * Word2007 footer part writer: word/footerx.xml.
24 */
25class Footer extends AbstractPart
26{
27    /**
28     * Root element name.
29     *
30     * @var string
31     */
32    protected $rootElement = 'w:ftr';
33
34    /**
35     * Footer/header element to be written.
36     *
37     * @var \PhpOffice\PhpWord\Element\Footer
38     */
39    protected $element;
40
41    /**
42     * Write part.
43     *
44     * @return string
45     */
46    public function write()
47    {
48        $xmlWriter = $this->getXmlWriter();
49        $drawingSchema = 'http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing';
50
51        $xmlWriter->startDocument('1.0', 'UTF-8', 'yes');
52        $xmlWriter->startElement($this->rootElement);
53        $xmlWriter->writeAttribute('xmlns:ve', 'http://schemas.openxmlformats.org/markup-compatibility/2006');
54        $xmlWriter->writeAttribute('xmlns:o', 'urn:schemas-microsoft-com:office:office');
55        $xmlWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships');
56        $xmlWriter->writeAttribute('xmlns:m', 'http://schemas.openxmlformats.org/officeDocument/2006/math');
57        $xmlWriter->writeAttribute('xmlns:v', 'urn:schemas-microsoft-com:vml');
58        $xmlWriter->writeAttribute('xmlns:wp', $drawingSchema);
59        $xmlWriter->writeAttribute('xmlns:w10', 'urn:schemas-microsoft-com:office:word');
60        $xmlWriter->writeAttribute('xmlns:w', 'http://schemas.openxmlformats.org/wordprocessingml/2006/main');
61        $xmlWriter->writeAttribute('xmlns:wne', 'http://schemas.microsoft.com/office/word/2006/wordml');
62
63        $containerWriter = new Container($xmlWriter, $this->element);
64        $containerWriter->write();
65
66        $xmlWriter->endElement(); // $this->rootElement
67
68        return $xmlWriter->getData();
69    }
70
71    /**
72     * Set element.
73     *
74     * @param \PhpOffice\PhpWord\Element\Footer|\PhpOffice\PhpWord\Element\Header $element
75     *
76     * @return self
77     */
78    public function setElement($element)
79    {
80        $this->element = $element;
81
82        return $this;
83    }
84}