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.

Signature::fromSignatureData()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 3

Importance

Changes 0
Metric Value
cc 3
eloc 5
nc 3
nop 2
dl 0
loc 10
ccs 6
cts 6
cp 1
crap 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace Sop\CryptoTypes\Signature;
6
7
use Sop\ASN1\Type\Primitive\BitString;
8
use Sop\CryptoTypes\AlgorithmIdentifier\Feature\AlgorithmIdentifierType;
9
use Sop\CryptoTypes\AlgorithmIdentifier\Signature\ECSignatureAlgorithmIdentifier;
10
use Sop\CryptoTypes\AlgorithmIdentifier\Signature\RSASignatureAlgorithmIdentifier;
11
12
/**
13
 * Base class for signature values.
14
 */
15
abstract class Signature
16
{
17
    /**
18
     * Get the signature as a BitString.
19
     *
20
     * @return BitString
21
     */
22
    abstract public function bitString(): BitString;
23
24
    /**
25
     * Get signature object by signature data and used algorithm.
26
     *
27
     * @param string                  $data Signature value
28
     * @param AlgorithmIdentifierType $algo Algorithm identifier
29
     *
30
     * @return self
31
     */
32 3
    public static function fromSignatureData(string $data,
33
        AlgorithmIdentifierType $algo): Signature
34
    {
35 3
        if ($algo instanceof RSASignatureAlgorithmIdentifier) {
36 1
            return RSASignature::fromSignatureString($data);
37
        }
38 2
        if ($algo instanceof ECSignatureAlgorithmIdentifier) {
39 1
            return ECSignature::fromDER($data);
40
        }
41 1
        return new GenericSignature(new BitString($data), $algo);
42
    }
43
}
44