Completed
Push — feature/middleware ( 308431...0268bb )
by Romain
02:25
created

ajaxControllerFormDataArgumentNotSet()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 10
rs 9.4285
cc 1
eloc 5
nc 1
nop 0
1
<?php
2
/*
3
 * 2017 Romain CANON <[email protected]>
4
 *
5
 * This file is part of the TYPO3 FormZ project.
6
 * It is free software; you can redistribute it and/or modify it
7
 * under the terms of the GNU General Public License, either
8
 * version 3 of the License, or any later version.
9
 *
10
 * For the full copyright and license information, see:
11
 * http://www.gnu.org/licenses/gpl-3.0.html
12
 */
13
14
namespace Romm\Formz\Exceptions;
15
16
use Romm\Formz\Middleware\Signal\SendsMiddlewareSignal;
17
18
class MissingArgumentException extends FormzException
19
{
20
    const ARGUMENT_MISSING = 'The argument "%s" was not found in the request.';
21
22
    const CONDITION_CONSTRUCTOR_ARGUMENT_MISSING = 'Error while instantiating the condition "%s" of type "%s": a constructor argument is missing. Given arguments were: "%s".';
23
24
    const SIGNAL_NAME_MISSING = 'No signal has been given to the signal dispatcher, used in the middleware "%s". This is because this middleware can dispatch several signals (namely "%s"); so you must indicate which signal to dispatch.';
25
26
    /**
27
     * @code 1490179179
28
     *
29
     * @return self
30
     */
31
    final public static function ajaxControllerNameArgumentNotSet()
32
    {
33
        /** @var self $exception */
34
        $exception = self::getNewExceptionInstance(
35
            self::ARGUMENT_MISSING,
36
            ['name']
37
        );
38
39
        return $exception;
40
    }
41
42
    /**
43
     * @code 1490179250
44
     *
45
     * @return self
46
     */
47
    final public static function ajaxControllerClassNameArgumentNotSet()
48
    {
49
        /** @var self $exception */
50
        $exception = self::getNewExceptionInstance(
51
            self::ARGUMENT_MISSING,
52
            ['className']
53
        );
54
55
        return $exception;
56
    }
57
58
    /**
59
     * @code 1502192265
60
     *
61
     * @return self
62
     */
63
    final public static function ajaxControllerFormDataArgumentNotSet()
64
    {
65
        /** @var self $exception */
66
        $exception = self::getNewExceptionInstance(
67
            self::ARGUMENT_MISSING,
68
            ['formData']
69
        );
70
71
        return $exception;
72
    }
73
74
    /**
75
     * @code 1494850270
76
     *
77
     * @param string $conditionName
78
     * @param string $conditionClassName
79
     * @param array  $arguments
80
     * @return self
81
     */
82
    final public static function conditionConstructorArgumentMissing($conditionName, $conditionClassName, array $arguments)
83
    {
84
        /** @var self $exception */
85
        $exception = self::getNewExceptionInstance(
86
            self::CONDITION_CONSTRUCTOR_ARGUMENT_MISSING,
87
            [$conditionName, $conditionClassName, implode('", "', array_keys($arguments))]
88
        );
89
90
        return $exception;
91
    }
92
93
    /**
94
     * @code 1490793826
95
     *
96
     * @param SendsMiddlewareSignal $middleware
97
     * @return self
98
     */
99
    final public static function signalNameArgumentMissing(SendsMiddlewareSignal $middleware)
100
    {
101
        /** @var self $exception */
102
        $exception = self::getNewExceptionInstance(
103
            self::SIGNAL_NAME_MISSING,
104
            [
105
                get_class($middleware),
106
                implode('", "', $middleware->getAllowedSignals())
107
            ]
108
        );
109
110
        return $exception;
111
    }
112
}
113