Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
10 / 10 |
|
100.00% |
6 / 6 |
CRAP | |
100.00% |
1 / 1 |
| Footer | |
100.00% |
10 / 10 |
|
100.00% |
6 / 6 |
7 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
1 | |||
| setType | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
2 | |||
| getType | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| resetType | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| firstPage | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| evenPage | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * This file is part of PHPWord - A pure PHP library for reading and writing |
| 5 | * word processing documents. |
| 6 | * |
| 7 | * PHPWord is free software distributed under the terms of the GNU Lesser |
| 8 | * General Public License version 3 as published by the Free Software Foundation. |
| 9 | * |
| 10 | * For the full copyright and license information, please read the LICENSE |
| 11 | * file that was distributed with this source code. For the full list of |
| 12 | * contributors, visit https://github.com/PHPOffice/PHPWord/contributors. |
| 13 | * |
| 14 | * @see https://github.com/PHPOffice/PHPWord |
| 15 | * |
| 16 | * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 |
| 17 | */ |
| 18 | |
| 19 | namespace PhpOffice\PhpWord\Element; |
| 20 | |
| 21 | /** |
| 22 | * Footer element. |
| 23 | */ |
| 24 | class Footer extends AbstractContainer |
| 25 | { |
| 26 | /** |
| 27 | * Header/footer types constants. |
| 28 | * |
| 29 | * @var string |
| 30 | * |
| 31 | * @see http://www.datypic.com/sc/ooxml/t-w_ST_HdrFtr.html Header or Footer Type |
| 32 | */ |
| 33 | const AUTO = 'default'; // default and odd pages |
| 34 | const FIRST = 'first'; |
| 35 | const EVEN = 'even'; |
| 36 | |
| 37 | /** |
| 38 | * @var string Container type |
| 39 | */ |
| 40 | protected $container = 'Footer'; |
| 41 | |
| 42 | /** |
| 43 | * Header type. |
| 44 | * |
| 45 | * @var string |
| 46 | */ |
| 47 | protected $type = self::AUTO; |
| 48 | |
| 49 | /** |
| 50 | * Create new instance. |
| 51 | * |
| 52 | * @param int $sectionId |
| 53 | * @param int $containerId |
| 54 | * @param string $type |
| 55 | */ |
| 56 | public function __construct($sectionId, $containerId = 1, $type = self::AUTO) |
| 57 | { |
| 58 | $this->sectionId = $sectionId; |
| 59 | $this->setType($type); |
| 60 | $this->setDocPart($this->container, ($sectionId - 1) * 3 + $containerId); |
| 61 | } |
| 62 | |
| 63 | /** |
| 64 | * Set type. |
| 65 | * |
| 66 | * @since 0.10.0 |
| 67 | * |
| 68 | * @param string $value |
| 69 | */ |
| 70 | public function setType($value = self::AUTO): void |
| 71 | { |
| 72 | if (!in_array($value, [self::AUTO, self::FIRST, self::EVEN])) { |
| 73 | $value = self::AUTO; |
| 74 | } |
| 75 | $this->type = $value; |
| 76 | } |
| 77 | |
| 78 | /** |
| 79 | * Get type. |
| 80 | * |
| 81 | * @return string |
| 82 | * |
| 83 | * @since 0.10.0 |
| 84 | */ |
| 85 | public function getType() |
| 86 | { |
| 87 | return $this->type; |
| 88 | } |
| 89 | |
| 90 | /** |
| 91 | * Reset type to default. |
| 92 | * |
| 93 | * @return string |
| 94 | */ |
| 95 | public function resetType() |
| 96 | { |
| 97 | return $this->type = self::AUTO; |
| 98 | } |
| 99 | |
| 100 | /** |
| 101 | * First page only header. |
| 102 | * |
| 103 | * @return string |
| 104 | */ |
| 105 | public function firstPage() |
| 106 | { |
| 107 | return $this->type = self::FIRST; |
| 108 | } |
| 109 | |
| 110 | /** |
| 111 | * Even numbered pages only. |
| 112 | * |
| 113 | * @return string |
| 114 | */ |
| 115 | public function evenPage() |
| 116 | { |
| 117 | return $this->type = self::EVEN; |
| 118 | } |
| 119 | } |