Tag::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 5
ccs 4
cts 4
cp 1
rs 10
cc 1
nc 1
nop 3
crap 1
1
<?php
2
3
namespace Ocsp\Asn1;
4
5
/**
6
 * Class used to tag ASN.1 elements.
7
 */
8
class Tag
9
{
10
    /**
11
     * Tag environment: IMPLICIT.
12
     *
13
     * @var string
14
     */
15
    const ENVIRONMENT_IMPLICIT = 'IMPLICIT';
16
17
    /**
18
     * Tag environment: EXPLICIT.
19
     *
20
     * @var string
21
     */
22
    const ENVIRONMENT_EXPLICIT = 'EXPLICIT';
23
24
    /**
25
     * The tag envoronment (the value of one of the Tag::ENVIRONMENT_... class constants).
26
     *
27
     * @var string
28
     */
29
    private $environment;
30
31
    /**
32
     * The tag ID.
33
     *
34
     * @var int|string|\phpseclib\Math\BigInteger|\phpseclib3\Math\BigInteger
0 ignored issues
show
Bug introduced by
The type phpseclib\Math\BigInteger was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
35
     */
36
    private $tagID;
37
38
    /**
39
     * The class (the value of one of the Element::CLASS_... constants).
40
     *
41
     * @var string
42
     */
43
    private $class;
44
45
    /**
46
     * Create a new instante.
47
     *
48
     * @param string $environment the tag envoronment (the value of one of the Tag::ENVIRONMENT_... class constants)
49
     * @param int|string|\phpseclib\Math\BigInteger|\phpseclib3\Math\BigInteger $tagID the tag ID
50
     * @param string $class the class (the value of one of the Element::CLASS_... constants)
51
     */
52 3
    protected function __construct($environment, $tagID, $class)
53
    {
54 3
        $this->environment = $environment;
55 3
        $this->tagID = $tagID;
56 3
        $this->class = $class;
57
    }
58
59
    /**
60
     * Get the tag envoronment (the value of one of the Tag::ENVIRONMENT_... class constants).
61
     *
62
     * @return string
63
     */
64 3
    public function getEnvironment()
65
    {
66 3
        return $this->environment;
67
    }
68
69
    /**
70
     * Get the tag ID.
71
     *
72
     * @return int|string|\phpseclib\Math\BigInteger|\phpseclib3\Math\BigInteger
73
     */
74 3
    public function getTagID()
75
    {
76 3
        return $this->tagID;
77
    }
78
79
    /**
80
     * Get the class (the value of one of the Element::CLASS_... constants).
81
     *
82
     * @return string
83
     */
84 3
    public function getClass()
85
    {
86 3
        return $this->class;
87
    }
88
89
    /**
90
     * Create a new IMPLICIT tag.
91
     *
92
     * @param int|string|\phpseclib\Math\BigInteger|\phpseclib3\Math\BigInteger $tagID the tag ID
93
     * @param string $class the class (the value of one of the Element::CLASS_... constants)
94
     *
95
     * @return static
96
     */
97
    public static function implicit($tagID, $class = Element::CLASS_CONTEXTSPECIFIC)
98
    {
99
        return new static(static::ENVIRONMENT_IMPLICIT, $tagID, $class);
100
    }
101
102
    /**
103
     * Create a new EXPLICIT tag.
104
     *
105
     * @param int|string|\phpseclib\Math\BigInteger|\phpseclib3\Math\BigInteger $tagID the tag ID
106
     * @param string $class the class (the value of one of the Element::CLASS_... constants)
107
     *
108
     * @return static
109
     */
110 3
    public static function explicit($tagID, $class = Element::CLASS_CONTEXTSPECIFIC)
111
    {
112 3
        return new static(static::ENVIRONMENT_EXPLICIT, $tagID, $class);
113
    }
114
}
115