PcreRegexException   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 0
loc 28
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 3
1
<?php
2
3
namespace Gobie\Regex\Wrappers\Pcre;
4
5
use Gobie\Regex\Wrappers\RegexException;
6
7
class PcreRegexException extends RegexException
8
{
9
10
    public static $messages = array(
11
        \PREG_INTERNAL_ERROR        => 'Internal error',
12
        \PREG_BACKTRACK_LIMIT_ERROR => 'Backtrack limit was exhausted',
13
        \PREG_RECURSION_LIMIT_ERROR => 'Recursion limit was exhausted',
14
        \PREG_BAD_UTF8_ERROR        => 'Malformed UTF-8 data',
15
        // HHVM fix, constant PREG_BAD_UTF8_OFFSET_ERROR replaced by its number
16
        5                           => 'The offset didn\'t correspond to the begin of a valid UTF-8 code point',
17
    );
18
19
    /**
20
     * If code is provided, but no message, it uses default PREG error messages.
21
     *
22
     * @param string               $message Message
23
     * @param int|null             $code    Code
24
     * @param string|string[]|null $pattern Pattern
25
     */
26 63
    public function __construct($message, $code = null, $pattern = null)
27
    {
28 63
        if (!$message && isset(self::$messages[$code])) {
29 18
            $message = self::$messages[$code];
30
        }
31
32 63
        parent::__construct($message, $code, $pattern);
33 63
    }
34
}
35