CertificateException::signContent()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 0
cts 3
cp 0
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 0
crap 2
1
<?php
2
3
namespace XmlSigner\Exception;
4
5
class CertificateException extends \RuntimeException implements ExceptionInterface
6
{
7
    public static function invalidSignature()
8
    {
9
        return new static(
10
            'An error has occurred when verify signature, ' . self::openSSLError()
11
        );
12
    }
13
14 1
    public static function privateKey()
15
    {
16 1
        return new static(
17 1
            'An error has occurred when get private key, ' . self::openSSLError()
18
        );
19
    }
20
21
    public static function publicKey()
22
    {
23
        return new static(
24
            'An error has occurred when read public key, ' . self::openSSLError()
25
        );
26
    }
27
28
    public static function signContent()
29
    {
30
        return new static(
31
            'An unexpected error has occurred when sign a content, ' . self::openSSLError()
32
        );
33
    }
34
35 1
    public static function unableToRead()
36
    {
37 1
        return new static(
38 1
            'Unable to read certificate, ' . self::openSSLError()
39
        );
40
    }
41
42 2
    private static function openSSLError()
43
    {
44 2
        $error = 'get follow error: ';
45 2
        while ($msg = openssl_error_string()) {
46 2
            $error .= "($msg)";
47
        }
48 2
        return $error;
49
    }
50
}
51