Completed
Push — feature/middleware-tmp ( 6341c7...1a9094 )
by Romain
02:14
created

InvalidEntryException::persistenceInvalidEntryFetched()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 14
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 14
rs 9.4285
cc 2
eloc 8
nc 2
nop 2
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\Item\AbstractMiddleware;
17
use Romm\Formz\Middleware\Signal\SendsMiddlewareSignal;
18
19
class InvalidEntryException extends FormzException
20
{
21
    const INVALID_CSS_CLASS_NAMESPACE = 'The class "%s" is not valid: the namespace of the error must be one of the following: %s.';
22
23
    const MIDDLEWARE_NOT_SENDING_SIGNALS = 'The middleware "%s" does not implement interface "%s", therefore it can not dispatch signals.';
24
25
    const PERSISTENCE_INVALID_ENTRY_FETCHED = 'The form instance fetched from persistence service "%s" is not valid: an instance of "%s" is awaited, result is of type "%s".';
26
27
    /**
28
     * @code 1467623504
29
     *
30
     * @param string $className
31
     * @param array  $acceptedClassesNameSpace
32
     * @return self
33
     */
34
    final public static function invalidCssClassNamespace($className, array $acceptedClassesNameSpace)
35
    {
36
        /** @var self $exception */
37
        $exception = self::getNewExceptionInstance(
38
            self::INVALID_CSS_CLASS_NAMESPACE,
39
            [$className, implode(', ', $acceptedClassesNameSpace)]
40
        );
41
42
        return $exception;
43
    }
44
45
    /**
46
     * @code 1490798324
47
     *
48
     * @param AbstractMiddleware $middleware
49
     * @return InvalidEntryException
50
     */
51
    final public static function middlewareNotSendingSignals(AbstractMiddleware $middleware)
52
    {
53
        /** @var self $exception */
54
        $exception = self::getNewExceptionInstance(
55
            self::MIDDLEWARE_NOT_SENDING_SIGNALS,
56
            [get_class($middleware), SendsMiddlewareSignal::class]
57
        );
58
59
        return $exception;
60
    }
61
}
62