IPhoneNumberUtil.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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;
  8. /**
  9. * @since 28.0.0
  10. */
  11. interface IPhoneNumberUtil {
  12. /**
  13. * Returns the country code for a specific region
  14. *
  15. * For example, this would be `41` for Switzerland and `49` for Germany.
  16. * Returns null when the region is invalid.
  17. *
  18. * @param string $regionCode Two-letter region code of ISO 3166-1
  19. * @return int|null Null when invalid/unsupported, the phone country code otherwise
  20. * @since 28.0.0
  21. */
  22. public function getCountryCodeForRegion(string $regionCode): ?int;
  23. /**
  24. * Converts a given input into an E164 formatted phone number
  25. *
  26. * E164 is the international format without any formatting characters or spaces.
  27. * E.g. +41446681800 where +41 is the region code.
  28. *
  29. * @param string $input Input phone number can contain formatting spaces, slashes and dashes
  30. * @param string|null $defaultRegion Two-letter region code of ISO 3166-1
  31. * @return string|null Null when the input is invalid for the given region or requires a region.
  32. * @since 28.0.0
  33. */
  34. public function convertToStandardFormat(string $input, ?string $defaultRegion = null): ?string;
  35. }