Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
7 / 7
100.00% covered (success)
100.00%
4 / 4
CRAP
100.00% covered (success)
100.00%
1 / 1
TrackChange
100.00% covered (success)
100.00%
7 / 7
100.00% covered (success)
100.00%
4 / 4
7
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
4
 getAuthor
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getDate
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getChangeType
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
20use DateTime;
21
22/**
23 * TrackChange element.
24 *
25 * @see http://datypic.com/sc/ooxml/t-w_CT_TrackChange.html
26 * @see http://datypic.com/sc/ooxml/t-w_CT_RunTrackChange.html
27 */
28class TrackChange extends AbstractContainer
29{
30    const INSERTED = 'INSERTED';
31    const DELETED = 'DELETED';
32
33    /**
34     * @var string Container type
35     */
36    protected $container = 'TrackChange';
37
38    /**
39     * The type of change, (insert or delete), not applicable for PhpOffice\PhpWord\Element\Comment.
40     *
41     * @var string
42     */
43    private $changeType;
44
45    /**
46     * Author.
47     *
48     * @var string
49     */
50    private $author;
51
52    /**
53     * Date.
54     *
55     * @var DateTime
56     */
57    private $date;
58
59    /**
60     * Create a new TrackChange Element.
61     *
62     * @param string $changeType
63     * @param string $author
64     * @param null|bool|DateTime|int $date
65     */
66    public function __construct($changeType = null, $author = null, $date = null)
67    {
68        $this->changeType = $changeType;
69        $this->author = $author;
70        if ($date !== null && $date !== false) {
71            $this->date = ($date instanceof DateTime) ? $date : new DateTime('@' . $date);
72        }
73    }
74
75    /**
76     * Get TrackChange Author.
77     *
78     * @return string
79     */
80    public function getAuthor()
81    {
82        return $this->author;
83    }
84
85    /**
86     * Get TrackChange Date.
87     *
88     * @return DateTime
89     */
90    public function getDate()
91    {
92        return $this->date;
93    }
94
95    /**
96     * Get the Change type.
97     *
98     * @return string
99     */
100    public function getChangeType()
101    {
102        return $this->changeType;
103    }
104}