ARateLimit.php 845 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OCP\AppFramework\Http\Attribute;
  8. /**
  9. * Attribute for controller methods that want to limit the times a logged-in
  10. * user can call the endpoint in a given time period.
  11. *
  12. * @since 27.0.0
  13. */
  14. abstract class ARateLimit {
  15. /**
  16. * @param int $limit The maximum number of requests that can be made in the given period in seconds.
  17. * @param int $period The time period in seconds.
  18. * @since 27.0.0
  19. */
  20. public function __construct(
  21. protected int $limit,
  22. protected int $period,
  23. ) {
  24. }
  25. /**
  26. * @since 27.0.0
  27. */
  28. public function getLimit(): int {
  29. return $this->limit;
  30. }
  31. /**
  32. * @since 27.0.0
  33. */
  34. public function getPeriod(): int {
  35. return $this->period;
  36. }
  37. }