Passed
Push — main ( 1e579d...c0f50c )
by
unknown
08:04 queued 03:57
created

RouterException::dynamicController()   A

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 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 3
ccs 1
cts 1
cp 1
crap 1
rs 10
1
<?php
2
3
/**
4
 * This file is part of Blitz PHP framework.
5
 *
6
 * (c) 2022 Dimitri Sitchet Tomkeu <[email protected]>
7
 *
8
 * For the full copyright and license information, please view
9
 * the LICENSE file that was distributed with this source code.
10
 */
11
12
namespace BlitzPHP\Exceptions;
13
14
/**
15
 * RouterException
16
 */
17
class RouterException extends FrameworkException
18
{
19
    /**
20
     * Levé lorsque le type de paramètre réel ne correspond pas
21
     * les types attendus.
22
     *
23
     * @return RouterException
24
     */
25
    public static function invalidParameterType()
26
    {
27 2
        return new static(lang('Router.invalidParameterType'));
28
    }
29
30
    /**
31
     * Levée lorsqu'une route par défaut n'est pas définie.
32
     *
33
     * @return RouterException
34
     */
35
    public static function missingDefaultRoute()
36
    {
37
        return new static(lang('Router.missingDefaultRoute'));
38
    }
39
40
    /**
41
     * Lancer lorsque le contrôleur ou sa méthode est introuvable.
42
     *
43
     * @return RouterException
44
     */
45
    public static function controllerNotFound(string $controller, string $method)
46
    {
47
        return new static(lang('HTTP.controllerNotFound', [$controller, $method]));
48
    }
49
50
    /**
51
     * Lancer lorsque la route n'est pas valide.
52
     *
53
     * @return RouterException
54
     */
55
    public static function invalidRoute(string $route)
56
    {
57
        return new static(lang('HTTP.invalidRoute', [$route]));
58
    }
59
60
    /**
61
     * Throw when dynamic controller.
62
     *
63
     * @return RouterException
64
     */
65
    public static function dynamicController(string $handler)
66
    {
67 2
        return new static(lang('Router.invalidDynamicController', [$handler]));
68
    }
69
70
    /**
71
     * Throw when controller name has `/`.
72
     *
73
     * @return RouterException
74
     */
75
    public static function invalidControllerName(string $handler)
76
    {
77 2
        return new static(lang('Router.invalidControllerName', [$handler]));
78
    }
79
}
80