| 1 |
<?php |
| 2 |
|
| 3 |
declare(strict_types=1); |
| 4 |
|
| 5 |
namespace SpomkyLabs\Pki\X509\GeneralName; |
| 6 |
|
| 7 |
use SpomkyLabs\Pki\ASN1\Type\Primitive\IA5String; |
| 8 |
use SpomkyLabs\Pki\ASN1\Type\Tagged\ImplicitlyTaggedType; |
| 9 |
use SpomkyLabs\Pki\ASN1\Type\TaggedType; |
| 10 |
use SpomkyLabs\Pki\ASN1\Type\UnspecifiedType; |
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
final class RFC822Name extends GeneralName |
| 18 |
{ |
| 19 |
private function __construct( |
| 20 |
private readonly string $email |
| 21 |
) { |
| 22 |
parent::__construct(self::TAG_RFC822_NAME); |
| 23 |
} |
| 24 |
|
| 25 |
public static function create(string $email): self |
| 26 |
{ |
| 27 |
return new self($email); |
| 28 |
} |
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
public static function fromChosenASN1(UnspecifiedType $el): GeneralName |
| 34 |
{ |
| 35 |
return self::create($el->asIA5String()->string()); |
| 36 |
} |
| 37 |
|
| 38 |
public function string(): string |
| 39 |
{ |
| 40 |
return $this->email; |
| 41 |
} |
| 42 |
|
| 43 |
public function email(): string |
| 44 |
{ |
| 45 |
return $this->email; |
| 46 |
} |
| 47 |
|
| 48 |
protected function choiceASN1(): TaggedType |
| 49 |
{ |
| 50 |
return ImplicitlyTaggedType::create($this->tag, IA5String::create($this->email)); |
| 51 |
} |
| 52 |
} |