event.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <?php
  2. /**
  3. * @author Morris Jobke <hey@morrisjobke.de>
  4. * @author Robin Appelman <icewind@owncloud.com>
  5. *
  6. * @copyright Copyright (c) 2015, ownCloud, Inc.
  7. * @license AGPL-3.0
  8. *
  9. * This code is free software: you can redistribute it and/or modify
  10. * it under the terms of the GNU Affero General Public License, version 3,
  11. * as published by the Free Software Foundation.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU Affero General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Affero General Public License, version 3,
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>
  20. *
  21. */
  22. namespace OC\Diagnostics;
  23. use OCP\Diagnostics\IEvent;
  24. class Event implements IEvent {
  25. /**
  26. * @var string
  27. */
  28. protected $id;
  29. /**
  30. * @var float
  31. */
  32. protected $start;
  33. /**
  34. * @var float
  35. */
  36. protected $end;
  37. /**
  38. * @var string
  39. */
  40. protected $description;
  41. /**
  42. * @param string $id
  43. * @param string $description
  44. * @param float $start
  45. */
  46. public function __construct($id, $description, $start) {
  47. $this->id = $id;
  48. $this->description = $description;
  49. $this->start = $start;
  50. }
  51. /**
  52. * @param float $time
  53. */
  54. public function end($time) {
  55. $this->end = $time;
  56. }
  57. /**
  58. * @return float
  59. */
  60. public function getStart() {
  61. return $this->start;
  62. }
  63. /**
  64. * @return string
  65. */
  66. public function getId() {
  67. return $this->id;
  68. }
  69. /**
  70. * @return string
  71. */
  72. public function getDescription() {
  73. return $this->description;
  74. }
  75. /**
  76. * @return float
  77. */
  78. public function getEnd() {
  79. return $this->end;
  80. }
  81. /**
  82. * @return float
  83. */
  84. public function getDuration() {
  85. if (!$this->end) {
  86. $this->end = microtime(true);
  87. }
  88. return $this->end - $this->start;
  89. }
  90. }