Passed
Pull Request — master (#190)
by Arman
04:05
created

RouteException::nameBeforeDefinition()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
/**
4
 * Quantum PHP Framework
5
 *
6
 * An open source software development framework for PHP
7
 *
8
 * @package Quantum
9
 * @author Arman Ag. <[email protected]>
10
 * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org)
11
 * @link http://quantum.softberg.org/
12
 * @since 2.9.5
13
 */
14
15
namespace Quantum\Router\Exceptions;
16
17
use Quantum\Exceptions\BaseException;
18
19
/**
20
 * Class RouteException
21
 * @package Quantum\Exceptions
22
 */
23
class RouteException extends BaseException
24
{
25
    /**
26
     * @return RouteException
27
     */
28
    public static function notFound(): RouteException
29
    {
30
        return new static(t('exception.route_not_found'), E_ERROR);
31
    }
32
33
    /**
34
     * @return RouteException
35
     */
36
    public static function notClosure(): RouteException
37
    {
38
        return new static(t('exception.routes_not_closure'), E_WARNING);
39
    }
40
41
    /**
42
     * @param string $name
43
     * @return RouteException
44
     */
45
    public static function repetitiveRouteSameMethod(string $name): RouteException
46
    {
47
        return new static(t('exception.repetitive_route_same_method', $name), E_WARNING);
48
    }
49
50
    /**
51
     * @return RouteException
52
     */
53
    public static function repetitiveRouteDifferentModules(): RouteException
54
    {
55
        return new static(t('exception.repetitive_route_different_modules'), E_WARNING);
56
    }
57
58
    /**
59
     * @param string|null $name
60
     * @return RouteException
61
     */
62
    public static function incorrectMethod(?string $name): RouteException
63
    {
64
        return new static(t('exception.incorrect_method', $name), E_WARNING);
65
    }
66
67
    /**
68
     * @return RouteException
69
     */
70
    public static function nameBeforeDefinition(): RouteException
71
    {
72
        return new static(t('exception.name_before_route_definition'));
73
    }
74
75
    /**
76
     * @return RouteException
77
     */
78
    public static function nameOnGroup(): RouteException
79
    {
80
        return new static(t('exception.name_on_group'));
81
    }
82
83
    /**
84
     * @return RouteException
85
     */
86
    public static function nonUniqueName(): RouteException
87
    {
88
        return new static(t('exception.name_is_not_unique'));
89
    }
90
91
    /**
92
     * @param string $name
93
     * @return RouteException
94
     */
95
    public static function paramNameNotAvailable(string $name): RouteException
96
    {
97
        return new static(t('exception.param_name_not_available', $name), E_WARNING);
98
    }
99
100
    /**
101
     * @return RouteException
102
     */
103
    public static function paramNameNotValid(): RouteException
104
    {
105
        return new static(t('exception.param_name_not_valid'), E_WARNING);
106
    }
107
}