Something went wrong. Try again.
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940<?php
declare(strict_types=1);
namespace Wotnak\Atproto\Identity;
/** * Resolves DNS TXT records using PHP's native DNS functions. * * @api */final class NativeDnsTxtResolver implements DnsTxtResolverInterface {
/** * {@inheritdoc} */ public function resolveTxt(string $name): array { $records = \dns_get_record($name, DNS_TXT); if ($records === FALSE) { return []; }
$values = []; foreach ($records as $record) { if (isset($record['txt']) && \is_string($record['txt'])) { $values[] = $record['txt']; continue; } if (isset($record['entries']) && \is_array($record['entries'])) { $value = \implode('', \array_filter($record['entries'], 'is_string')); if ($value !== '') { $values[] = $value; } } } return $values; }
}