Something went wrong. Try again.
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142<?php
declare(strict_types=1);
namespace Wotnak\Atproto\Identifier;
/** * Value object for a normalized NSID. * * @api */final readonly class Nsid {
public function __construct( public string $value, public string $authority, public string $name, ) { if (!NsidParser::isValid($value)) { throw new \InvalidArgumentException(\sprintf('Invalid NSID "%s".', $value)); } $parts = \explode('.', $value); $parsedName = \array_pop($parts); $parsedAuthority = \strtolower(\implode('.', $parts)); if ( $authority !== $parsedAuthority || $name !== $parsedName || $value !== $parsedAuthority . '.' . $parsedName ) { throw new \InvalidArgumentException('NSID components do not match the normalized value.'); } }
/** * Returns the canonical string representation. */ public function __toString(): string { return $this->value; }
}