CoreFiles by mySites.guru
RFC822Name.php52 lines, 1,180 bytes, from Joomla_5.2.2-Stable-Full_Package.zip
Raw History Compare with 5.2.1
md5
e1a786c1df2730bd01fd2730490f2b01
sha1
917b95d49ae651b2beb0f4049e9dcb8934a5126c
sha256
2cdb8ce21f3140155dbb1d61a75e49d100cc70ce84547440a2a8111ec383d2d4
<?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 *rfc822Name* CHOICE type of *GeneralName*.
 *
 * @see https://tools.ietf.org/html/rfc5280#section-4.2.1.6
 */
final class RFC822Name extends GeneralName
{
    private function __construct(
        private readonly string $email
    ) {
        parent::__construct(self::TAG_RFC822_NAME);
    }

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

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

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

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

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

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.