mirror of
https://github.com/Respect/Validation.git
synced 2026-03-16 23:35:45 +01:00
We've always considered renaming this directory, as it's not a common standard to name `library` the directory where the source code of a library it. Having it as `src/` is a common pattern we find in several PHP libraries these days. Acked-by: Alexandre Gomes Gaigalas <alganet@gmail.com>
42 lines
1 KiB
PHP
42 lines
1 KiB
PHP
<?php
|
|
|
|
/*
|
|
* SPDX-License-Identifier: MIT
|
|
* SPDX-FileCopyrightText: (c) Respect Project Contributors
|
|
* SPDX-FileContributor: Alexandre Gomes Gaigalas <alganet@gmail.com>
|
|
* SPDX-FileContributor: Henrique Moody <henriquemoody@gmail.com>
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Respect\Validation\Helpers;
|
|
|
|
use function file_exists;
|
|
use function mb_strtoupper;
|
|
|
|
final class DomainInfo
|
|
{
|
|
/** @var mixed[] */
|
|
private readonly array $data;
|
|
|
|
/** @var mixed[] */
|
|
private static array $runtimeCache = [];
|
|
|
|
public function __construct(string $tld)
|
|
{
|
|
$tld = mb_strtoupper($tld);
|
|
|
|
if (!isset(static::$runtimeCache[$tld])) {
|
|
$filename = __DIR__ . '/../../data/domain/public-suffix/' . $tld . '.php';
|
|
static::$runtimeCache[$tld] = file_exists($filename) ? require $filename : [];
|
|
}
|
|
|
|
$this->data = static::$runtimeCache[$tld];
|
|
}
|
|
|
|
/** @return array<string> */
|
|
public function getPublicSuffixes(): array
|
|
{
|
|
return $this->data;
|
|
}
|
|
}
|