CoreFiles by mySites.guru
DNSName.php58 lines, 1,256 bytes, from Joomla_6.1.2-Stable-Full_Package.zip
Raw History Compare with 6.1.1
md5
39f755d306099befa386e24ae35c3402
sha1
89aab03513b88c90499c490d62ec2f8c5b3db3b8
sha256
f8596388b94aa622a04e2334ac83dc706b98da11b5afe25f9e8a8383327a2764
<?php

declare(strict_types=1);

namespace SpomkyLabs\Pki\X509\GeneralName;

use SpomkyLabs\Pki\ASN1\Type\Primitive\IA5String;
use SpomkyLabs\Pki\ASN1\Type\Tagged\ImplicitlyTaggedType;
use SpomkyLabs\Pki\ASN1\Type\TaggedType;
use SpomkyLabs\Pki\ASN1\Type\UnspecifiedType;

/**
 * Implements *dNSName* CHOICE type of *GeneralName*.
 *
 * @see https://tools.ietf.org/html/rfc5280#section-4.2.1.6
 */
final class DNSName extends GeneralName
{
    /**
     * @param string $name Domain name
     */
    private function __construct(
        private readonly string $name
    ) {
        parent::__construct(self::TAG_DNS_NAME);
    }

    public static function create(string $name): self
    {
        return new self($name);
    }

    /**
     * @return self
     */
    public static function fromChosenASN1(UnspecifiedType $el): GeneralName
    {
        return self::create($el->asIA5String()->string());
    }

    public function string(): string
    {
        return $this->name;
    }

    /**
     * Get DNS name.
     */
    public function name(): string
    {
        return $this->name;
    }

    protected function choiceASN1(): TaggedType
    {
        return ImplicitlyTaggedType::create($this->tag, IA5String::create($this->name));
    }
}

The same content is in 158 releases, Joomla 5.0.0-alpha1 to 6.3.0-alpha1. See them all, or every version of this file.