InhibitAnyPolicyExtension::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 5
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
nc 1
cc 1
nop 2
crap 1
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace X509\Certificate\Extension;
6
7
use ASN1\Type\UnspecifiedType;
8
use ASN1\Type\Primitive\Integer;
9
10
/**
11
 * Implements 'Inhibit anyPolicy' extension.
12
 *
13
 * @link https://tools.ietf.org/html/rfc5280#section-4.2.1.14
14
 */
15
class InhibitAnyPolicyExtension extends Extension
16
{
17
    /**
18
     *
19
     * @var int $_skipCerts
20
     */
21
    protected $_skipCerts;
22
    
23
    /**
24
     * Constructor.
25
     *
26
     * @param bool $critical
27
     * @param int $skip_certs
28
     */
29 10
    public function __construct(bool $critical, int $skip_certs)
30
    {
31 10
        parent::__construct(self::OID_INHIBIT_ANY_POLICY, $critical);
32 10
        $this->_skipCerts = $skip_certs;
33 10
    }
34
    
35
    /**
36
     *
37
     * {@inheritdoc}
38
     * @return self
39
     */
40 9
    protected static function _fromDER(string $data, bool $critical): self
41
    {
42 9
        return new self($critical,
43 9
            UnspecifiedType::fromDER($data)->asInteger()->intNumber());
44
    }
45
    
46
    /**
47
     * Get value.
48
     *
49
     * @return int
50
     */
51 4
    public function skipCerts(): int
52
    {
53 4
        return $this->_skipCerts;
54
    }
55
    
56
    /**
57
     *
58
     * {@inheritdoc}
59
     * @return Integer
60
     */
61 17
    protected function _valueASN1(): Integer
62
    {
63 17
        return new Integer($this->_skipCerts);
64
    }
65
}
66