Passed
Push — master ( a4ac02...aea3c7 )
by Tim
13:22
created

OpenSSLException::__construct()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 7
nc 4
nop 1
dl 0
loc 13
rs 10
c 1
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\XMLSecurity\Exception;
6
7
/**
8
 * Class OpenSSLException
9
 *
10
 * This exception is thrown when an error occurs during a call to the openssl backend.
11
 *
12
 * @package simplesamlphp/xml-security
13
 */
14
class OpenSSLException extends RuntimeException
15
{
16
    /**
17
     * @param string $message
18
     */
19
    public function __construct(string $message = 'Generic OpenSSL exception')
20
    {
21
        $stack = [];
22
        while (($msg = openssl_error_string()) !== false) {
23
            $stack[] = $msg;
24
        }
25
26
        foreach ($stack as $line) {
27
            $message .= '; ' . $line;
28
        }
29
        $message .= '.';
30
31
        parent::__construct($message);
32
    }
33
}
34