Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
10 / 10
100.00% covered (success)
100.00%
6 / 6
CRAP
100.00% covered (success)
100.00%
1 / 1
Footer
100.00% covered (success)
100.00%
10 / 10
100.00% covered (success)
100.00%
6 / 6
7
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
1
 setType
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
2
 getType
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 resetType
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 firstPage
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 evenPage
100.00% covered (success)
100.00%
1 / 1
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\Element;
19
20/**
21 * Footer element.
22 */
23class Footer extends AbstractContainer
24{
25    /**
26     * Header/footer types constants.
27     *
28     * @var string
29     *
30     * @see  http://www.datypic.com/sc/ooxml/t-w_ST_HdrFtr.html Header or Footer Type
31     */
32    const AUTO = 'default';  // default and odd pages
33    const FIRST = 'first';
34    const EVEN = 'even';
35
36    /**
37     * @var string Container type
38     */
39    protected $container = 'Footer';
40
41    /**
42     * Header type.
43     *
44     * @var string
45     */
46    protected $type = self::AUTO;
47
48    /**
49     * Create new instance.
50     *
51     * @param int $sectionId
52     * @param int $containerId
53     * @param string $type
54     */
55    public function __construct($sectionId, $containerId = 1, $type = self::AUTO)
56    {
57        $this->sectionId = $sectionId;
58        $this->setType($type);
59        $this->setDocPart($this->container, ($sectionId - 1) * 3 + $containerId);
60    }
61
62    /**
63     * Set type.
64     *
65     * @since 0.10.0
66     *
67     * @param string $value
68     */
69    public function setType($value = self::AUTO): void
70    {
71        if (!in_array($value, [self::AUTO, self::FIRST, self::EVEN])) {
72            $value = self::AUTO;
73        }
74        $this->type = $value;
75    }
76
77    /**
78     * Get type.
79     *
80     * @return string
81     *
82     * @since 0.10.0
83     */
84    public function getType()
85    {
86        return $this->type;
87    }
88
89    /**
90     * Reset type to default.
91     *
92     * @return string
93     */
94    public function resetType()
95    {
96        return $this->type = self::AUTO;
97    }
98
99    /**
100     * First page only header.
101     *
102     * @return string
103     */
104    public function firstPage()
105    {
106        return $this->type = self::FIRST;
107    }
108
109    /**
110     * Even numbered pages only.
111     *
112     * @return string
113     */
114    public function evenPage()
115    {
116        return $this->type = self::EVEN;
117    }
118}