UniqueIdentifier   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 71
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 1
dl 0
loc 71
ccs 13
cts 13
cp 1
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A fromASN1() 0 4 1
A fromString() 0 4 1
A string() 0 4 1
A bitString() 0 4 1
A toASN1() 0 4 1
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace X509\Certificate;
6
7
use ASN1\Type\Primitive\BitString;
8
9
/**
10
 * Implements <i>UniqueIdentifier</i> ASN.1 type.
11
 *
12
 * @link https://tools.ietf.org/html/rfc5280#section-4.1.2.8
13
 */
14
class UniqueIdentifier
15
{
16
    /**
17
     * Identifier.
18
     *
19
     * @var BitString $_uid
20
     */
21
    protected $_uid;
22
    
23
    /**
24
     * Constructor.
25
     *
26
     * @param BitString $bs
27
     */
28 16
    public function __construct(BitString $bs)
29
    {
30 16
        $this->_uid = $bs;
31 16
    }
32
    
33
    /**
34
     * Initialize from ASN.1.
35
     *
36
     * @param BitString $bs
37
     * @return self
38
     */
39 4
    public static function fromASN1(BitString $bs): UniqueIdentifier
40
    {
41 4
        return new self($bs);
42
    }
43
    
44
    /**
45
     * Initialize from string.
46
     *
47
     * @param string $str
48
     * @return self
49
     */
50 12
    public static function fromString(string $str): UniqueIdentifier
51
    {
52 12
        return new self(new BitString($str));
53
    }
54
    
55
    /**
56
     * Get unique identifier as a string.
57
     *
58
     * @return string
59
     */
60 6
    public function string(): string
61
    {
62 6
        return $this->_uid->string();
63
    }
64
    
65
    /**
66
     * Get unique identifier as a bit string.
67
     *
68
     * @return BitString
69
     */
70 1
    public function bitString(): BitString
71
    {
72 1
        return $this->_uid;
73
    }
74
    
75
    /**
76
     * Get ASN.1 element.
77
     *
78
     * @return BitString
79
     */
80 12
    public function toASN1(): BitString
81
    {
82 12
        return $this->_uid;
83
    }
84
}
85