abstract.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <?php
  2. /**
  3. * ZeroBin
  4. *
  5. * a zero-knowledge paste bin
  6. *
  7. * @link http://sebsauvage.net/wiki/doku.php?id=php:zerobin
  8. * @copyright 2012 Sébastien SAUVAGE (sebsauvage.net)
  9. * @license http://www.opensource.org/licenses/zlib-license.php The zlib/libpng License
  10. * @version 0.15
  11. */
  12. /**
  13. * zerobin_abstract
  14. *
  15. * Abstract model for ZeroBin data access, implemented as a singleton.
  16. */
  17. abstract class zerobin_abstract
  18. {
  19. /**
  20. * singleton instance
  21. *
  22. * @access private
  23. * @static
  24. * @var zerobin
  25. */
  26. protected static $_instance = null;
  27. /**
  28. * enforce singleton, disable constructor
  29. *
  30. * Instantiate using {@link getInstance()}, zerobin is a singleton object.
  31. *
  32. * @access protected
  33. */
  34. protected function __construct() {}
  35. /**
  36. * enforce singleton, disable cloning
  37. *
  38. * Instantiate using {@link getInstance()}, zerobin is a singleton object.
  39. *
  40. * @access private
  41. */
  42. private function __clone() {}
  43. /**
  44. * get instance of singleton
  45. *
  46. * @access public
  47. * @static
  48. * @return zerobin
  49. */
  50. abstract public static function getInstance($options);
  51. /**
  52. * Create a paste.
  53. *
  54. * @access public
  55. * @param string $pasteid
  56. * @param array $paste
  57. * @return int|false
  58. */
  59. abstract public function create($pasteid, $paste);
  60. /**
  61. * Read a paste.
  62. *
  63. * @access public
  64. * @param string $pasteid
  65. * @return string
  66. */
  67. abstract public function read($pasteid);
  68. /**
  69. * Delete a paste and its discussion.
  70. *
  71. * @access public
  72. * @param string $pasteid
  73. * @return void
  74. */
  75. abstract public function delete($pasteid);
  76. /**
  77. * Test if a paste exists.
  78. *
  79. * @access public
  80. * @param string $dataid
  81. * @return void
  82. */
  83. abstract public function exists($pasteid);
  84. /**
  85. * Create a comment in a paste.
  86. *
  87. * @access public
  88. * @param string $pasteid
  89. * @param string $parentid
  90. * @param string $commentid
  91. * @param array $comment
  92. * @return int|false
  93. */
  94. abstract public function createComment($pasteid, $parentid, $commentid, $comment);
  95. /**
  96. * Read all comments of paste.
  97. *
  98. * @access public
  99. * @param string $pasteid
  100. * @return array
  101. */
  102. abstract public function readComments($pasteid);
  103. /**
  104. * Test if a comment exists.
  105. *
  106. * @access public
  107. * @param string $dataid
  108. * @param string $parentid
  109. * @param string $commentid
  110. * @return void
  111. */
  112. abstract public function existsComment($pasteid, $parentid, $commentid);
  113. }