Passed
Pull Request — master (#22)
by Rhodri
08:06
created

FilesystemException   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 11
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
b 0
f 0
dl 0
loc 11
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A createFromPhpError() 0 9 2
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