Passed
Pull Request — master (#43)
by Arman
03:54
created

ControllerException::undefinedMethod()   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
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
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.5.0
13
 */
14
15
namespace Quantum\Exceptions;
16
17
/**
18
 * ControllerException class
19
 *
20
 * @package Quantum
21
 * @category Exceptions
22
 */
23
class ControllerException extends \Exception
24
{
25
    /**
26
     * Controller not found message
27
     */
28
    const CONTROLLER_NOT_FOUND = 'Controller `{%1}` not found';
29
30
    /**
31
     * Controller not defined message
32
     */
33
    const CONTROLLER_NOT_DEFINED = 'Controller {%1} not defined';
34
35
    /**
36
     * Action not defined message
37
     */
38
    const ACTION_NOT_DEFINED = 'Action `{%1}` not defined';
39
40
    /**
41
     * Undefined method
42
     */
43
    const UNDEFINED_METHOD = 'The method `{%1}` is not defined';
44
45
    /**
46
     * @param string|null $name
47
     * @return \Quantum\Exceptions\ControllerException
48
     */
49
    public static function controllerNotFound(?string $name): ControllerException
50
    {
51
        return new static(_message(self::CONTROLLER_NOT_FOUND, $name), E_ERROR);
52
    }
53
54
    /**
55
     * @param string|null $name
56
     * @return \Quantum\Exceptions\ControllerException
57
     */
58
    public static function controllerNotDefined(?string $name): ControllerException
59
    {
60
        return new static(_message(self::CONTROLLER_NOT_DEFINED, $name), E_ERROR);
61
    }
62
63
    /**
64
     * @param string $name
65
     * @return \Quantum\Exceptions\ControllerException
66
     */
67
    public static function actionNotDefined(string $name): ControllerException
68
    {
69
        return new static(_message(self::ACTION_NOT_DEFINED, $name), E_ERROR);
70
    }
71
72
    /**
73
     * @param string $name
74
     * @return \Quantum\Exceptions\ControllerException
75
     */
76
    public static function undefinedMethod(string $name): ControllerException
77
    {
78
        return new static(_message(self::UNDEFINED_METHOD, $name), E_ERROR);
79
    }
80
}
81