Completed
Push — master ( 120fc0...97cb31 )
by Julien
33s queued 11s
created

FilesystemException::createFromPhpError()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 4
c 1
b 0
f 0
nc 2
nop 0
dl 0
loc 9
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace TheCodingMachine\Gotenberg;
6
7
use ErrorException;
8
use RuntimeException;
9
use function error_get_last;
10
11
class FilesystemException extends ErrorException
12
{
13
    public static function createFromPhpError(): self
14
    {
15
        $error = error_get_last();
16
17
        if ($error === null) {
18
            throw new RuntimeException('No error information available');
19
        }
20
21
        return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
22
    }
23
}
24