GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Push — master ( 95c197...564e5e )
by Joni
04:32
created

StringType   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 1
dl 0
loc 47
ccs 11
cts 11
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __toString() 0 3 1
A string() 0 3 1
A __construct() 0 8 2
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace Sop\ASN1\Type;
6
7
use Sop\ASN1\Element;
8
use Sop\ASN1\Feature\Stringable;
9
10
/**
11
 * Base class for all string types.
12
 */
13
abstract class StringType extends Element implements Stringable
14
{
15
    /**
16
     * String value.
17
     *
18
     * @var string
19
     */
20
    protected $_string;
21
22
    /**
23
     * Constructor.
24
     *
25
     * @param string $string
26
     *
27
     * @throws \InvalidArgumentException
28
     */
29 121
    public function __construct(string $string)
30
    {
31 121
        if (!$this->_validateString($string)) {
32 8
            throw new \InvalidArgumentException(
33 8
                sprintf('Not a valid %s string.',
34 8
                    self::tagToName($this->_typeTag)));
35
        }
36 113
        $this->_string = $string;
37 113
    }
38
39
    /**
40
     * {@inheritdoc}
41
     *
42
     * @return string
43
     */
44 1
    public function __toString(): string
45
    {
46 1
        return $this->string();
47
    }
48
49
    /**
50
     * Get the string value.
51
     *
52
     * @return string
53
     */
54 35
    public function string(): string
55
    {
56 35
        return $this->_string;
57
    }
58
59
    /**
60
     * Check whether string is valid for the concrete type.
61
     *
62
     * @param string $string
63
     *
64
     * @return bool
65
     */
66 65
    protected function _validateString(string $string): bool
67
    {
68
        // Override in derived classes
69 65
        return true;
70
    }
71
}
72