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.

BaseString   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
eloc 9
dl 0
loc 46
ccs 12
cts 12
cp 1
rs 10
c 1
b 0
f 0

4 Methods

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