session.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. /**
  3. * Copyright (c) 2013 Robin Appelman <icewind@owncloud.com>
  4. * This file is licensed under the Affero General Public License version 3 or
  5. * later.
  6. * See the COPYING-README file.
  7. */
  8. namespace OC\Session;
  9. abstract class Session implements \ArrayAccess {
  10. /**
  11. * $name serves as a namespace for the session keys
  12. *
  13. * @param string $name
  14. */
  15. abstract public function __construct($name);
  16. /**
  17. * @param string $key
  18. * @param mixed $value
  19. */
  20. abstract public function set($key, $value);
  21. /**
  22. * @param string $key
  23. * @return mixed should return null if $key does not exist
  24. */
  25. abstract public function get($key);
  26. /**
  27. * @param string $key
  28. * @return bool
  29. */
  30. abstract public function exists($key);
  31. /**
  32. * should not throw any errors if $key does not exist
  33. *
  34. * @param string $key
  35. */
  36. abstract public function remove($key);
  37. /**
  38. * removes all entries within the cache namespace
  39. */
  40. abstract public function clear();
  41. /**
  42. * @param mixed $offset
  43. * @return bool
  44. */
  45. public function offsetExists($offset) {
  46. return $this->exists($offset);
  47. }
  48. /**
  49. * @param mixed $offset
  50. * @return mixed
  51. */
  52. public function offsetGet($offset) {
  53. return $this->get($offset);
  54. }
  55. /**
  56. * @param mixed $offset
  57. * @param mixed $value
  58. */
  59. public function offsetSet($offset, $value) {
  60. $this->set($offset, $value);
  61. }
  62. /**
  63. * @param mixed $offset
  64. */
  65. public function offsetUnset($offset) {
  66. $this->remove($offset);
  67. }
  68. }