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   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 27
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A fromSignatureData() 0 10 3
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