OpenSSLException::__construct()   A
last analyzed

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
     */
18
    public function __construct(string $message = 'Generic OpenSSL exception')
19
    {
20
        $stack = [];
21
        while (($msg = openssl_error_string()) !== false) {
22
            $stack[] = $msg;
23
        }
24
25
        foreach ($stack as $line) {
26
            $message .= '; ' . $line;
27
        }
28
        $message .= '.';
29
30
        parent::__construct($message);
31
    }
32
}
33