IRange.php 616 B

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OCP\Security\Ip;
  8. /**
  9. * IP Range (IPv4 or IPv6)
  10. *
  11. * @since 30.0.0
  12. */
  13. interface IRange {
  14. /**
  15. * Check if a given range is valid
  16. *
  17. * @since 30.0.0
  18. */
  19. public static function isValid(string $range): bool;
  20. /**
  21. * Check if an address is in the current range
  22. *
  23. * @since 30.0.0
  24. */
  25. public function contains(IAddress $address): bool;
  26. /**
  27. * Normalized IP range
  28. *
  29. * @since 30.0.0
  30. */
  31. public function __toString(): string;
  32. }