IComment.php 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
  6. * @author Thomas Müller <thomas.mueller@tmit.eu>
  7. *
  8. * @license AGPL-3.0
  9. *
  10. * This code is free software: you can redistribute it and/or modify
  11. * it under the terms of the GNU Affero General Public License, version 3,
  12. * as published by the Free Software Foundation.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU Affero General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Affero General Public License, version 3,
  20. * along with this program. If not, see <http://www.gnu.org/licenses/>
  21. *
  22. */
  23. namespace OCP\Comments;
  24. /**
  25. * Interface IComment
  26. *
  27. * This class represents a comment
  28. *
  29. * @package OCP\Comments
  30. * @since 9.0.0
  31. */
  32. interface IComment {
  33. const MAX_MESSAGE_LENGTH = 1000;
  34. /**
  35. * returns the ID of the comment
  36. *
  37. * It may return an empty string, if the comment was not stored.
  38. * It is expected that the concrete Comment implementation gives an ID
  39. * by itself (e.g. after saving).
  40. *
  41. * @return string
  42. * @since 9.0.0
  43. */
  44. public function getId();
  45. /**
  46. * sets the ID of the comment and returns itself
  47. *
  48. * It is only allowed to set the ID only, if the current id is an empty
  49. * string (which means it is not stored in a database, storage or whatever
  50. * the concrete implementation does), or vice versa. Changing a given ID is
  51. * not permitted and must result in an IllegalIDChangeException.
  52. *
  53. * @param string $id
  54. * @return IComment
  55. * @throws IllegalIDChangeException
  56. * @since 9.0.0
  57. */
  58. public function setId($id);
  59. /**
  60. * returns the parent ID of the comment
  61. *
  62. * @return string
  63. * @since 9.0.0
  64. */
  65. public function getParentId();
  66. /**
  67. * sets the parent ID and returns itself
  68. * @param string $parentId
  69. * @return IComment
  70. * @since 9.0.0
  71. */
  72. public function setParentId($parentId);
  73. /**
  74. * returns the topmost parent ID of the comment
  75. *
  76. * @return string
  77. * @since 9.0.0
  78. */
  79. public function getTopmostParentId();
  80. /**
  81. * sets the topmost parent ID and returns itself
  82. *
  83. * @param string $id
  84. * @return IComment
  85. * @since 9.0.0
  86. */
  87. public function setTopmostParentId($id);
  88. /**
  89. * returns the number of children
  90. *
  91. * @return int
  92. * @since 9.0.0
  93. */
  94. public function getChildrenCount();
  95. /**
  96. * sets the number of children
  97. *
  98. * @param int $count
  99. * @return IComment
  100. * @since 9.0.0
  101. */
  102. public function setChildrenCount($count);
  103. /**
  104. * returns the message of the comment
  105. *
  106. * @return string
  107. * @since 9.0.0
  108. */
  109. public function getMessage();
  110. /**
  111. * sets the message of the comment and returns itself
  112. *
  113. * When the given message length exceeds MAX_MESSAGE_LENGTH an
  114. * MessageTooLongException shall be thrown.
  115. *
  116. * @param string $message
  117. * @return IComment
  118. * @throws MessageTooLongException
  119. * @since 9.0.0
  120. */
  121. public function setMessage($message);
  122. /**
  123. * returns the verb of the comment
  124. *
  125. * @return string
  126. * @since 9.0.0
  127. */
  128. public function getVerb();
  129. /**
  130. * sets the verb of the comment, e.g. 'comment' or 'like'
  131. *
  132. * @param string $verb
  133. * @return IComment
  134. * @since 9.0.0
  135. */
  136. public function setVerb($verb);
  137. /**
  138. * returns the actor type
  139. *
  140. * @return string
  141. * @since 9.0.0
  142. */
  143. public function getActorType();
  144. /**
  145. * returns the actor ID
  146. *
  147. * @return string
  148. * @since 9.0.0
  149. */
  150. public function getActorId();
  151. /**
  152. * sets (overwrites) the actor type and id
  153. *
  154. * @param string $actorType e.g. 'users'
  155. * @param string $actorId e.g. 'zombie234'
  156. * @return IComment
  157. * @since 9.0.0
  158. */
  159. public function setActor($actorType, $actorId);
  160. /**
  161. * returns the creation date of the comment.
  162. *
  163. * If not explicitly set, it shall default to the time of initialization.
  164. *
  165. * @return \DateTime
  166. * @since 9.0.0
  167. */
  168. public function getCreationDateTime();
  169. /**
  170. * sets the creation date of the comment and returns itself
  171. *
  172. * @param \DateTime $dateTime
  173. * @return IComment
  174. * @since 9.0.0
  175. */
  176. public function setCreationDateTime(\DateTime $dateTime);
  177. /**
  178. * returns the date of the most recent child
  179. *
  180. * @return \DateTime
  181. * @since 9.0.0
  182. */
  183. public function getLatestChildDateTime();
  184. /**
  185. * sets the date of the most recent child
  186. *
  187. * @param \DateTime $dateTime
  188. * @return IComment
  189. * @since 9.0.0
  190. */
  191. public function setLatestChildDateTime(\DateTime $dateTime);
  192. /**
  193. * returns the object type the comment is attached to
  194. *
  195. * @return string
  196. * @since 9.0.0
  197. */
  198. public function getObjectType();
  199. /**
  200. * returns the object id the comment is attached to
  201. *
  202. * @return string
  203. * @since 9.0.0
  204. */
  205. public function getObjectId();
  206. /**
  207. * sets (overwrites) the object of the comment
  208. *
  209. * @param string $objectType e.g. 'files'
  210. * @param string $objectId e.g. '16435'
  211. * @return IComment
  212. * @since 9.0.0
  213. */
  214. public function setObject($objectType, $objectId);
  215. }