EDIPartyName::string()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
nc 1
cc 1
nop 0
crap 1
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace X509\GeneralName;
6
7
use ASN1\Type\TaggedType;
8
use ASN1\Type\UnspecifiedType;
9
use ASN1\Type\Tagged\ImplicitlyTaggedType;
10
11
/**
12
 * Implements <i>ediPartyName</i> CHOICE type of <i>GeneralName</i>.
13
 *
14
 * Currently acts as a parking object for decoding.
15
 *
16
 * @link https://tools.ietf.org/html/rfc5280#section-4.2.1.6
17
 * @todo Implement EDIPartyName type
18
 */
19
class EDIPartyName extends GeneralName
20
{
21
    /**
22
     *
23
     * @var \ASN1\Element
24
     */
25
    protected $_element;
26
    
27
    /**
28
     * Constructor.
29
     */
30 2
    protected function __construct()
31
    {
32 2
        $this->_tag = self::TAG_EDI_PARTY_NAME;
33 2
    }
34
    
35
    /**
36
     *
37
     * @param UnspecifiedType $el
38
     * @return self
39
     */
40 2
    public static function fromChosenASN1(UnspecifiedType $el): self
41
    {
42 2
        $obj = new self();
43 2
        $obj->_element = $el->asSequence();
44 2
        return $obj;
45
    }
46
    
47
    /**
48
     *
49
     * {@inheritdoc}
50
     */
51 1
    public function string(): string
52
    {
53 1
        return bin2hex($this->_element->toDER());
54
    }
55
    
56
    /**
57
     *
58
     * {@inheritdoc}
59
     */
60 1
    protected function _choiceASN1(): TaggedType
61
    {
62 1
        return new ImplicitlyTaggedType($this->_tag, $this->_element);
63
    }
64
}
65