Completed
Push — master ( 42c457...7978bf )
by Joni
03:43
created

SequenceOfAttributes::toASN1()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
dl 0
loc 6
ccs 4
cts 4
cp 1
rs 10
c 1
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace Sop\X501\ASN1\Collection;
6
7
use Sop\ASN1\Type\Constructed\Sequence;
8
use Sop\X501\ASN1\Attribute;
9
10
/**
11
 * Implements *Attributes* ASN.1 type as a *SEQUENCE OF Attribute*.
12
 *
13
 * Used in *AttributeCertificateInfo*.
14
 *
15
 * @see https://tools.ietf.org/html/rfc5755#section-4.1
16
 * @see https://tools.ietf.org/html/rfc5755#section-4.2.7
17
 */
18
class SequenceOfAttributes extends AttributeCollection
19
{
20
    /**
21
     * Initialize from ASN.1.
22
     *
23
     * @param Sequence $seq
24
     *
25
     * @return self
26
     */
27 2
    public static function fromASN1(Sequence $seq): self
28
    {
29 2
        return static::_fromASN1Structure($seq);
30
    }
31
32
    /**
33
     * Generate ASN.1 structure.
34
     *
35
     * @return Sequence
36
     */
37 2
    public function toASN1(): Sequence
38
    {
39 2
        return new Sequence(...array_map(
40
            function (Attribute $attr) {
41 2
                return $attr->toASN1();
42 2
            }, $this->_attributes));
43
    }
44
}
45