IProfile.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * @copyright 2022 Carl Schwan <carl@carlschwan.eu>
  5. *
  6. * @author Carl Schwan <carl@carlschwan.eu>
  7. *
  8. * @license GNU AGPL version 3 or any later version
  9. *
  10. * This program is free software: you can redistribute it and/or modify
  11. * it under the terms of the GNU Affero General Public License as
  12. * published by the Free Software Foundation, either version 3 of the
  13. * License, or (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU Affero General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU Affero General Public License
  21. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  22. *
  23. */
  24. namespace OCP\Profiler;
  25. use OCP\DataCollector\IDataCollector;
  26. /**
  27. * This interface store the results of the profiling of one
  28. * request. You can get the saved profiles from the @see IProfiler.
  29. *
  30. * ```php
  31. * <?php
  32. * $profiler = \OC::$server->get(IProfiler::class);
  33. * $profiles = $profiler->find('/settings/users', 10);
  34. * ```
  35. *
  36. * This interface is meant to be used directly and not extended.
  37. * @since 24.0.0
  38. */
  39. interface IProfile {
  40. /**
  41. * Get the token of the profile
  42. * @since 24.0.0
  43. */
  44. public function getToken(): string;
  45. /**
  46. * Set the token of the profile
  47. * @since 24.0.0
  48. */
  49. public function setToken(string $token): void;
  50. /**
  51. * Get the time of the profile
  52. * @since 24.0.0
  53. */
  54. public function getTime(): ?int;
  55. /**
  56. * Set the time of the profile
  57. * @since 24.0.0
  58. */
  59. public function setTime(int $time): void;
  60. /**
  61. * Get the url of the profile
  62. * @since 24.0.0
  63. */
  64. public function getUrl(): ?string;
  65. /**
  66. * Set the url of the profile
  67. * @since 24.0.0
  68. */
  69. public function setUrl(string $url): void;
  70. /**
  71. * Get the method of the profile
  72. * @since 24.0.0
  73. */
  74. public function getMethod(): ?string;
  75. /**
  76. * Set the method of the profile
  77. * @since 24.0.0
  78. */
  79. public function setMethod(string $method): void;
  80. /**
  81. * Get the status code of the profile
  82. * @since 24.0.0
  83. */
  84. public function getStatusCode(): ?int;
  85. /**
  86. * Set the status code of the profile
  87. * @since 24.0.0
  88. */
  89. public function setStatusCode(int $statusCode): void;
  90. /**
  91. * Add a data collector to the profile
  92. * @since 24.0.0
  93. */
  94. public function addCollector(IDataCollector $collector);
  95. /**
  96. * Get the parent profile to this profile
  97. * @since 24.0.0
  98. */
  99. public function getParent(): ?IProfile;
  100. /**
  101. * Set the parent profile to this profile
  102. * @since 24.0.0
  103. */
  104. public function setParent(?IProfile $parent): void;
  105. /**
  106. * Get the parent token to this profile
  107. * @since 24.0.0
  108. */
  109. public function getParentToken(): ?string;
  110. /**
  111. * Get the profile's children
  112. * @return IProfile[]
  113. * @since 24.0.0
  114. **/
  115. public function getChildren(): array;
  116. /**
  117. * Set the profile's children
  118. * @param IProfile[] $children
  119. * @since 24.0.0
  120. */
  121. public function setChildren(array $children): void;
  122. /**
  123. * Add the child profile
  124. * @since 24.0.0
  125. */
  126. public function addChild(IProfile $profile): void;
  127. /**
  128. * Get all the data collectors
  129. * @return IDataCollector[]
  130. * @since 24.0.0
  131. */
  132. public function getCollectors(): array;
  133. /**
  134. * Set all the data collectors
  135. * @param IDataCollector[] $collectors
  136. * @since 24.0.0
  137. */
  138. public function setCollectors(array $collectors): void;
  139. /**
  140. * Get a data collector by name
  141. * @since 24.0.0
  142. */
  143. public function getCollector(string $collectorName): ?IDataCollector;
  144. }