ParserException::squareBracketMismatch()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 1
cts 1
cp 1
crap 1
rs 10
1
<?php
2
namespace Lead\Router;
3
4
class ParserException extends \RuntimeException
5
{
6
    const SQUARE_BRACKET_MISMATCH = 1;
7
8
    const DUPLICATE_PLACEHOLDER = 2;
9
10
    const PLACEHOLDER_EXCEEDED = 3;
11
12
    /**
13
     * The missing placeholder name.
14
     *
15
     * @var string
16
     */
17
    public $placeholder = '';
18
19
    /**
20
     * The error code.
21
     *
22
     * @var integer
23
     */
24
    protected $code = 500;
25
26
    /**
27
     * Creates a square bracket mismatch exception.
28
     *
29
     * @return object
30
     */
31
    public static function squareBracketMismatch()
32
    {
33 2
        return new static("Number of opening '[' and closing ']' does not match.", static::SQUARE_BRACKET_MISMATCH);
34
    }
35
36
    /**
37
     * Creates a duplicate placeholder exception.
38
     *
39
     * @return object
40
     */
41
    public static function duplicatePlaceholder($placeholder = '')
42
    {
43 2
        $exception = new static("Cannot use the same placeholder `{$placeholder}` twice.", static::DUPLICATE_PLACEHOLDER);
44 2
        $exception->placeholder = $placeholder;
45 2
        return $exception;
46
    }
47
48
    /**
49
     * Creates a placeholder exceeded exception.
50
     *
51
     * @return object
52
     */
53
    public static function placeholderExceeded()
54
    {
55 2
        return new static("Only a single placeholder is allowed in repeatable segments.", static::PLACEHOLDER_EXCEEDED);
56
    }
57
}
58