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   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 55
ccs 13
cts 13
cp 1
rs 10
c 0
b 0
f 0
wmc 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A string() 0 3 1
A __construct() 0 8 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
     * @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