Passed
Push — master ( d10e8c...c6bdb0 )
by Joni
03:28
created

UnknownAttributeValue::_transcodedString()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
c 0
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\AttributeValue;
6
7
use Sop\ASN1\Element;
8
use Sop\X501\MatchingRule\BinaryMatch;
9
use Sop\X501\MatchingRule\MatchingRule;
10
11
/**
12
 * Class to hold ASN.1 structure of an unimplemented attribute value.
13
 */
14
class UnknownAttributeValue extends AttributeValue
15
{
16
    /**
17
     * ASN.1 element.
18
     *
19
     * @var Element
20
     */
21
    protected $_element;
22
23
    /**
24
     * Constructor.
25
     *
26
     * @param string  $oid
27
     * @param Element $el
28
     */
29 5
    public function __construct(string $oid, Element $el)
30
    {
31 5
        $this->_oid = $oid;
32 5
        $this->_element = $el;
33 5
    }
34
35
    /**
36
     * {@inheritdoc}
37
     */
38 3
    public function toASN1(): Element
39
    {
40 3
        return $this->_element;
41
    }
42
43
    /**
44
     * {@inheritdoc}
45
     */
46 6
    public function stringValue(): string
47
    {
48
        // return DER encoding as a hexstring
49 6
        return '#' . bin2hex($this->_element->toDER());
50
    }
51
52
    /**
53
     * {@inheritdoc}
54
     */
55 2
    public function equalityMatchingRule(): MatchingRule
56
    {
57 2
        return new BinaryMatch();
58
    }
59
60
    /**
61
     * {@inheritdoc}
62
     */
63 3
    public function rfc2253String(): string
64
    {
65 3
        return $this->stringValue();
66
    }
67
68
    /**
69
     * {@inheritdoc}
70
     */
71 1
    protected function _transcodedString(): string
72
    {
73 1
        return $this->stringValue();
74
    }
75
}
76