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 ( 662af5...44febf )
by Joni
02:17
created

BaseString::string()   A

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 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
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
     * @param string $string
25
     *
26
     * @throws \InvalidArgumentException
27
     */
28 136
    public function __construct(string $string)
29
    {
30 136
        if (!$this->_validateString($string)) {
31 8
            throw new \InvalidArgumentException(
32 8
                sprintf('Not a valid %s string.',
33 8
                    self::tagToName($this->_typeTag)));
34
        }
35 128
        $this->_string = $string;
36 128
    }
37
38
    /**
39
     * {@inheritdoc}
40
     */
41 1
    public function __toString(): string
42
    {
43 1
        return $this->string();
44
    }
45
46
    /**
47
     * Get the string value.
48
     *
49
     * @return string
50
     */
51 50
    public function string(): string
52
    {
53 50
        return $this->_string;
54
    }
55
56
    /**
57
     * Check whether string is valid for the concrete type.
58
     *
59
     * @param string $string
60
     *
61
     * @return bool
62
     */
63 69
    protected function _validateString(string $string): bool
64
    {
65
        // Override in derived classes
66 69
        return true;
67
    }
68
}
69