PhpHttpDriver.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. /*
  3. * This file is part of the DebugBar package.
  4. *
  5. * (c) 2013 Maxime Bouroumeau-Fuseau
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace DebugBar;
  11. /**
  12. * HTTP driver for native php
  13. */
  14. class PhpHttpDriver implements HttpDriverInterface
  15. {
  16. /**
  17. * @param array $headers
  18. */
  19. function setHeaders(array $headers)
  20. {
  21. foreach ($headers as $name => $value) {
  22. header("$name: $value");
  23. }
  24. }
  25. /**
  26. * @return bool
  27. */
  28. function isSessionStarted()
  29. {
  30. return isset($_SESSION);
  31. }
  32. /**
  33. * @param string $name
  34. * @param string $value
  35. */
  36. function setSessionValue($name, $value)
  37. {
  38. $_SESSION[$name] = $value;
  39. }
  40. /**
  41. * @param string $name
  42. * @return bool
  43. */
  44. function hasSessionValue($name)
  45. {
  46. return array_key_exists($name, $_SESSION);
  47. }
  48. /**
  49. * @param string $name
  50. * @return mixed
  51. */
  52. function getSessionValue($name)
  53. {
  54. return $_SESSION[$name];
  55. }
  56. /**
  57. * @param string $name
  58. */
  59. function deleteSessionValue($name)
  60. {
  61. unset($_SESSION[$name]);
  62. }
  63. }