Completed
Push — master ( 8c15b3...f8d4b2 )
by Arman
15s queued 11s
created

RouteException::notClosure()   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.9
13
 */
14
15
namespace Quantum\Router\Exceptions;
16
17
use Quantum\Router\Enums\ExceptionMessages;
18
use Quantum\App\Exceptions\BaseException;
19
20
/**
21
 * Class RouteException
22
 * @package Quantum\Exceptions
23
 */
24
class RouteException extends BaseException
25
{
26
    /**
27
     * @return RouteException
28
     */
29
    public static function routeNotFound(): RouteException
30
    {
31
        return new static(ExceptionMessages::ROUTE_NOT_FOUND, E_ERROR);
32
    }
33
34
    /**
35
     * @return RouteException
36
     */
37
    public static function notClosure(): RouteException
38
    {
39
        return new static(ExceptionMessages::ROUTE_NOT_CLOSURE, E_WARNING);
40
    }
41
42
    /**
43
     * @param string $name
44
     * @return RouteException
45
     */
46
    public static function repetitiveRouteSameMethod(string $name): RouteException
47
    {
48
        return new static(_message(ExceptionMessages::REPETITIVE_ROUTE_WITH_SAME_NAME, [$name]), E_WARNING);
49
    }
50
51
    /**
52
     * @return RouteException
53
     */
54
    public static function repetitiveRouteDifferentModules(): RouteException
55
    {
56
        return new static(ExceptionMessages::REPETITIVE_ROUTE_IN_DIFFERENT_MODULES, E_WARNING);
57
    }
58
59
    /**
60
     * @param string|null $name
61
     * @return RouteException
62
     */
63
    public static function incorrectMethod(?string $name): RouteException
64
    {
65
        return new static(_message(ExceptionMessages::INCORRECT_METHOD, [$name]), E_WARNING);
66
    }
67
68
    /**
69
     * @return RouteException
70
     */
71
    public static function nameBeforeDefinition(): RouteException
72
    {
73
        return new static(ExceptionMessages::NAME_BEFORE_ROUTE_DEFINITION, E_WARNING);
74
    }
75
76
    /**
77
     * @return RouteException
78
     */
79
    public static function nameOnGroup(): RouteException
80
    {
81
        return new static(ExceptionMessages::NAME_ON_ROUTE_GROUP, E_WARNING);
82
    }
83
84
    /**
85
     * @return RouteException
86
     */
87
    public static function nonUniqueName(): RouteException
88
    {
89
        return new static(ExceptionMessages::NAME_NOT_UNIQUE, E_WARNING);
90
    }
91
92
    /**
93
     * @param string $name
94
     * @return RouteException
95
     */
96
    public static function paramNameNotAvailable(string $name): RouteException
97
    {
98
        return new static(_message(ExceptionMessages::ROUTE_PARAM_NAME_IN_USE, [$name]), E_WARNING);
99
    }
100
101
    /**
102
     * @return RouteException
103
     */
104
    public static function paramNameNotValid(): RouteException
105
    {
106
        return new static(ExceptionMessages::INVALID_ROUTE_PARAM_NAME, E_WARNING);
107
    }
108
}