TrackChange.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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. * @copyright 2010-2018 PHPWord contributors
  15. * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
  16. */
  17. namespace PhpOffice\PhpWord\Element;
  18. /**
  19. * TrackChange element
  20. * @see http://datypic.com/sc/ooxml/t-w_CT_TrackChange.html
  21. * @see http://datypic.com/sc/ooxml/t-w_CT_RunTrackChange.html
  22. */
  23. class TrackChange extends AbstractContainer
  24. {
  25. const INSERTED = 'INSERTED';
  26. const DELETED = 'DELETED';
  27. /**
  28. * @var string Container type
  29. */
  30. protected $container = 'TrackChange';
  31. /**
  32. * The type of change, (insert or delete), not applicable for PhpOffice\PhpWord\Element\Comment
  33. *
  34. * @var string
  35. */
  36. private $changeType;
  37. /**
  38. * Author
  39. *
  40. * @var string
  41. */
  42. private $author;
  43. /**
  44. * Date
  45. *
  46. * @var \DateTime
  47. */
  48. private $date;
  49. /**
  50. * Create a new TrackChange Element
  51. *
  52. * @param string $changeType
  53. * @param string $author
  54. * @param null|int|bool|\DateTime $date
  55. */
  56. public function __construct($changeType = null, $author = null, $date = null)
  57. {
  58. $this->changeType = $changeType;
  59. $this->author = $author;
  60. if ($date !== null && $date !== false) {
  61. $this->date = ($date instanceof \DateTime) ? $date : new \DateTime('@' . $date);
  62. }
  63. }
  64. /**
  65. * Get TrackChange Author
  66. *
  67. * @return string
  68. */
  69. public function getAuthor()
  70. {
  71. return $this->author;
  72. }
  73. /**
  74. * Get TrackChange Date
  75. *
  76. * @return \DateTime
  77. */
  78. public function getDate()
  79. {
  80. return $this->date;
  81. }
  82. /**
  83. * Get the Change type
  84. *
  85. * @return string
  86. */
  87. public function getChangeType()
  88. {
  89. return $this->changeType;
  90. }
  91. }