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

SequenceOfAttributes   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 6
dl 0
loc 25
ccs 6
cts 6
cp 1
rs 10
c 1
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A fromASN1() 0 3 1
A toASN1() 0 6 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