GeneralizedTime::getClass()   A
last analyzed

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 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 0
crap 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