GeneralizedTime   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 81
Duplicated Lines 0 %

Test Coverage

Coverage 75%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 7
eloc 12
c 1
b 0
f 0
dl 0
loc 81
ccs 12
cts 16
cp 0.75
rs 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 0 5 1
A getClass() 0 3 1
A getTypeID() 0 3 1
A getEncodedValue() 0 3 1
A isConstructed() 0 3 1
A getValue() 0 3 1
A setValue() 0 5 1
1
<?php
2
3
namespace Ocsp\Asn1\Element;
4
5
use DateTimeImmutable;
6
use Ocsp\Asn1\Encoder;
7
use Ocsp\Asn1\TaggableElement;
8
use Ocsp\Asn1\TaggableElementTrait;
9
use Ocsp\Asn1\UniversalTagID;
10
11
/**
12
 * ASN.1 element: INTEGER.
13
 */
14
class GeneralizedTime implements TaggableElement
15
{
16
    use TaggableElementTrait;
17
18
    /**
19
     * @var \DateTimeImmutable
20
     */
21
    private $value;
22
23
    /**
24
     * Create a new instance.
25
     *
26
     * @param \DateTimeImmutable $value
27
     *
28
     * @return static
29
     */
30 2
    public static function create(DateTimeImmutable $value)
31
    {
32 2
        $result = new static();
33
34 2
        return $result->setValue($value);
35
    }
36
37
    /**
38
     * {@inheritdoc}
39
     *
40
     * @see \Ocsp\Asn1\Element::getClass()
41
     */
42 2
    public function getClass()
43
    {
44 2
        return static::CLASS_UNIVERSAL;
45
    }
46
47
    /**
48
     * {@inheritdoc}
49
     *
50
     * @see \Ocsp\Asn1\Element::getTypeID()
51
     */
52 2
    public function getTypeID()
53
    {
54 2
        return UniversalTagID::GENERALIZEDTIME;
55
    }
56
57
    /**
58
     * {@inheritdoc}
59
     *
60
     * @see \Ocsp\Asn1\Element::isConstructed()
61
     */
62
    public function isConstructed()
63
    {
64
        return false;
65
    }
66
67
    /**
68
     * @return \DateTimeImmutable
69
     */
70 2
    public function getValue()
71
    {
72 2
        return $this->value;
73
    }
74
75
    /**
76
     * @param \DateTimeImmutable $value
77
     *
78
     * @return $this
79
     */
80 2
    public function setValue(DateTimeImmutable $value)
81
    {
82 2
        $this->value = $value;
83
84 2
        return $this;
85
    }
86
87
    /**
88
     * {@inheritdoc}
89
     *
90
     * @see \Ocsp\Asn1\Element::getEncodedValue()
91
     */
92
    public function getEncodedValue(Encoder $encoder)
93
    {
94
        return $encoder->encodeGeneralizedTime($this->getValue());
95
    }
96
}
97