PublicDomainSuffix.php 709 B

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. /*
  3. * Copyright (c) Alexandre Gomes Gaigalas <alganet@gmail.com>
  4. * SPDX-License-Identifier: MIT
  5. */
  6. declare(strict_types=1);
  7. namespace Respect\Validation\Rules;
  8. use Respect\Validation\Helpers\DomainInfo;
  9. use function array_pop;
  10. use function explode;
  11. final class PublicDomainSuffix extends AbstractSearcher
  12. {
  13. /**
  14. * @var string[]
  15. */
  16. private $domainInfo;
  17. /**
  18. * {@inheritDoc}
  19. */
  20. protected function getDataSource($input = null): array
  21. {
  22. $parts = explode('.', $input);
  23. $tld = array_pop($parts);
  24. $domainInfo = new DomainInfo($tld);
  25. $this->domainInfo = $domainInfo->getPublicSuffixes();
  26. return $this->domainInfo;
  27. }
  28. }