event.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <?php
  2. /**
  3. * Copyright (c) 2014 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\Diagnostics;
  9. use OCP\Diagnostics\IEvent;
  10. class Event implements IEvent {
  11. /**
  12. * @var string
  13. */
  14. protected $id;
  15. /**
  16. * @var float
  17. */
  18. protected $start;
  19. /**
  20. * @var float
  21. */
  22. protected $end;
  23. /**
  24. * @var string
  25. */
  26. protected $description;
  27. /**
  28. * @param string $id
  29. * @param string $description
  30. * @param float $start
  31. */
  32. public function __construct($id, $description, $start) {
  33. $this->id = $id;
  34. $this->description = $description;
  35. $this->start = $start;
  36. }
  37. /**
  38. * @param float $time
  39. */
  40. public function end($time) {
  41. $this->end = $time;
  42. }
  43. /**
  44. * @return float
  45. */
  46. public function getStart() {
  47. return $this->start;
  48. }
  49. /**
  50. * @return string
  51. */
  52. public function getId() {
  53. return $this->id;
  54. }
  55. /**
  56. * @return string
  57. */
  58. public function getDescription() {
  59. return $this->description;
  60. }
  61. /**
  62. * @return float
  63. */
  64. public function getEnd() {
  65. return $this->end;
  66. }
  67. /**
  68. * @return float
  69. */
  70. public function getDuration() {
  71. if (!$this->end) {
  72. $this->end = microtime(true);
  73. }
  74. return $this->end - $this->start;
  75. }
  76. }