1
0

IProfile.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OCP\Profiler;
  8. use OCP\DataCollector\IDataCollector;
  9. /**
  10. * This interface store the results of the profiling of one
  11. * request. You can get the saved profiles from the @see IProfiler.
  12. *
  13. * ```php
  14. * <?php
  15. * $profiler = \OC::$server->get(IProfiler::class);
  16. * $profiles = $profiler->find('/settings/users', 10);
  17. * ```
  18. *
  19. * This interface is meant to be used directly and not extended.
  20. * @since 24.0.0
  21. */
  22. interface IProfile {
  23. /**
  24. * Get the token of the profile
  25. * @since 24.0.0
  26. */
  27. public function getToken(): string;
  28. /**
  29. * Set the token of the profile
  30. * @since 24.0.0
  31. */
  32. public function setToken(string $token): void;
  33. /**
  34. * Get the time of the profile
  35. * @since 24.0.0
  36. */
  37. public function getTime(): ?int;
  38. /**
  39. * Set the time of the profile
  40. * @since 24.0.0
  41. */
  42. public function setTime(int $time): void;
  43. /**
  44. * Get the url of the profile
  45. * @since 24.0.0
  46. */
  47. public function getUrl(): ?string;
  48. /**
  49. * Set the url of the profile
  50. * @since 24.0.0
  51. */
  52. public function setUrl(string $url): void;
  53. /**
  54. * Get the method of the profile
  55. * @since 24.0.0
  56. */
  57. public function getMethod(): ?string;
  58. /**
  59. * Set the method of the profile
  60. * @since 24.0.0
  61. */
  62. public function setMethod(string $method): void;
  63. /**
  64. * Get the status code of the profile
  65. * @since 24.0.0
  66. */
  67. public function getStatusCode(): ?int;
  68. /**
  69. * Set the status code of the profile
  70. * @since 24.0.0
  71. */
  72. public function setStatusCode(int $statusCode): void;
  73. /**
  74. * Add a data collector to the profile
  75. * @since 24.0.0
  76. */
  77. public function addCollector(IDataCollector $collector);
  78. /**
  79. * Get the parent profile to this profile
  80. * @since 24.0.0
  81. */
  82. public function getParent(): ?IProfile;
  83. /**
  84. * Set the parent profile to this profile
  85. * @since 24.0.0
  86. */
  87. public function setParent(?IProfile $parent): void;
  88. /**
  89. * Get the parent token to this profile
  90. * @since 24.0.0
  91. */
  92. public function getParentToken(): ?string;
  93. /**
  94. * Get the profile's children
  95. * @return IProfile[]
  96. * @since 24.0.0
  97. **/
  98. public function getChildren(): array;
  99. /**
  100. * Set the profile's children
  101. * @param IProfile[] $children
  102. * @since 24.0.0
  103. */
  104. public function setChildren(array $children): void;
  105. /**
  106. * Add the child profile
  107. * @since 24.0.0
  108. */
  109. public function addChild(IProfile $profile): void;
  110. /**
  111. * Get all the data collectors
  112. * @return IDataCollector[]
  113. * @since 24.0.0
  114. */
  115. public function getCollectors(): array;
  116. /**
  117. * Set all the data collectors
  118. * @param IDataCollector[] $collectors
  119. * @since 24.0.0
  120. */
  121. public function setCollectors(array $collectors): void;
  122. /**
  123. * Get a data collector by name
  124. * @since 24.0.0
  125. */
  126. public function getCollector(string $collectorName): ?IDataCollector;
  127. }