1
0

IPhoneNumberUtil.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. *
  5. * @copyright Copyright (c) 2023 Joas Schilling <coding@schilljs.com>
  6. *
  7. * @author Joas Schilling <coding@schilljs.com>
  8. *
  9. * @license GNU AGPL version 3 or any later version
  10. *
  11. * This program is free software: you can redistribute it and/or modify
  12. * it under the terms of the GNU Affero General Public License as
  13. * published by the Free Software Foundation, either version 3 of the
  14. * License, or (at your option) any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU Affero General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU Affero General Public License
  22. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  23. *
  24. */
  25. namespace OCP;
  26. /**
  27. * @since 28.0.0
  28. */
  29. interface IPhoneNumberUtil {
  30. /**
  31. * Returns the country code for a specific region
  32. *
  33. * For example, this would be `41` for Switzerland and `49` for Germany.
  34. * Returns null when the region is invalid.
  35. *
  36. * @param string $regionCode Two-letter region code of ISO 3166-1
  37. * @return int|null Null when invalid/unsupported, the phone country code otherwise
  38. * @since 28.0.0
  39. */
  40. public function getCountryCodeForRegion(string $regionCode): ?int;
  41. /**
  42. * Converts a given input into an E164 formatted phone number
  43. *
  44. * E164 is the international format without any formatting characters or spaces.
  45. * E.g. +41446681800 where +41 is the region code.
  46. *
  47. * @param string $input Input phone number can contain formatting spaces, slashes and dashes
  48. * @param string|null $defaultRegion Two-letter region code of ISO 3166-1
  49. * @return string|null Null when the input is invalid for the given region or requires a region.
  50. * @since 28.0.0
  51. */
  52. public function convertToStandardFormat(string $input, ?string $defaultRegion = null): ?string;
  53. }