CoreFiles by mySites.guru
SetOfAttributes.php47 lines, 1,270 bytes, from Joomla_5.2.4-Stable-Full_Package.zip
Raw History Compare with 5.2.3
md5
1a0226b203b78864239bb7832e6d30f7
sha1
c2556c3e7af51dce65b9b8adbf432a46fa9d415e
sha256
af672d350d9fd29693e58d3cecf90c30c94380eb0bf38d9a51df9c534607540d
<?php

declare(strict_types=1);

namespace SpomkyLabs\Pki\X501\ASN1\Collection;

use SpomkyLabs\Pki\ASN1\Type\Constructed\Set;
use SpomkyLabs\Pki\X501\ASN1\Attribute;
use SpomkyLabs\Pki\X501\ASN1\AttributeValue\AttributeValue;

/**
 * Implements *Attributes* ASN.1 type as a *SET OF Attribute*.
 *
 * Used in *CertificationRequestInfo* and *OneAsymmetricKey*.
 *
 * @see https://tools.ietf.org/html/rfc2986#section-4
 * @see https://tools.ietf.org/html/rfc5958#section-2
 */
class SetOfAttributes extends AttributeCollection
{
    /**
     * Initialize from ASN.1.
     */
    public static function fromASN1(Set $set): static
    {
        return static::_fromASN1Structure($set);
    }

    /**
     * Initialize from attribute values.
     *
     * @param AttributeValue ...$values List of attribute values
     */
    public static function fromAttributeValues(AttributeValue ...$values): static
    {
        return static::create(...array_map(static fn (AttributeValue $value) => $value->toAttribute(), $values));
    }

    /**
     * Generate ASN.1 structure.
     */
    public function toASN1(): Set
    {
        $set = Set::create(...array_map(static fn (Attribute $attr) => $attr->toASN1(), $this->_attributes));
        return $set->sortedSetOf();
    }
}

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.