Completed
Push — master ( d87057...f3ab30 )
by Jaap
28s queued 12s
created

PcreException   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 23
rs 10
c 0
b 0
f 0
wmc 8
lcom 0
cbo 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B createFromPhpError() 0 20 8
1
<?php
2
3
declare(strict_types=1);
4
5
namespace phpDocumentor\Reflection\Exception;
6
7
use InvalidArgumentException;
8
use const PREG_BACKTRACK_LIMIT_ERROR;
9
use const PREG_BAD_UTF8_ERROR;
10
use const PREG_BAD_UTF8_OFFSET_ERROR;
11
use const PREG_INTERNAL_ERROR;
12
use const PREG_JIT_STACKLIMIT_ERROR;
13
use const PREG_NO_ERROR;
14
use const PREG_RECURSION_LIMIT_ERROR;
15
16
final class PcreException extends InvalidArgumentException
17
{
18
    public static function createFromPhpError(int $errorCode) : self
19
    {
20
        switch ($errorCode) {
21
            case PREG_BACKTRACK_LIMIT_ERROR:
22
                return new self('Backtrack limit error');
23
            case PREG_RECURSION_LIMIT_ERROR:
24
                return new self('Recursion limit error');
25
            case PREG_BAD_UTF8_ERROR:
26
                return new self('Bad UTF8 error');
27
            case PREG_BAD_UTF8_OFFSET_ERROR:
28
                return new self('Bad UTF8 offset error');
29
            case PREG_JIT_STACKLIMIT_ERROR:
30
                return new self('Jit stacklimit error');
31
            case PREG_NO_ERROR:
32
            case PREG_INTERNAL_ERROR:
33
            default:
34
        }
35
36
        return new self('Unknown Pcre error');
37
    }
38
}
39