| 1 |
<?php |
| 2 |
|
| 3 |
declare(strict_types=1); |
| 4 |
|
| 5 |
namespace SpomkyLabs\Pki\X501\ASN1\Collection; |
| 6 |
|
| 7 |
use SpomkyLabs\Pki\ASN1\Type\Constructed\Set; |
| 8 |
use SpomkyLabs\Pki\X501\ASN1\Attribute; |
| 9 |
use SpomkyLabs\Pki\X501\ASN1\AttributeValue\AttributeValue; |
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
class SetOfAttributes extends AttributeCollection |
| 20 |
{ |
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
public static function fromASN1(Set $set): static |
| 25 |
{ |
| 26 |
return static::_fromASN1Structure($set); |
| 27 |
} |
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
public static function fromAttributeValues(AttributeValue ...$values): static |
| 35 |
{ |
| 36 |
return static::create(...array_map(static fn (AttributeValue $value) => $value->toAttribute(), $values)); |
| 37 |
} |
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
public function toASN1(): Set |
| 43 |
{ |
| 44 |
$set = Set::create(...array_map(static fn (Attribute $attr) => $attr->toASN1(), $this->_attributes)); |
| 45 |
return $set->sortedSetOf(); |
| 46 |
} |
| 47 |
} |