Completed
Push — master ( c41709...42f2c0 )
by Romain
9s
created

formViewHelperWrongFormValueClassName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
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\Form\FormInterface;
17
use TYPO3\CMS\Core\Cache\Backend\AbstractBackend;
18
19
class InvalidOptionValueException extends FormzException
20
{
21
    const WRONG_FORM_TYPE = 'The form class must be an instance of "%s", given value: "%s".';
22
23
    const WRONG_FORM_VALUE_TYPE = 'The form given in the argument `object` of `FormViewHelper` must be an instance of "%s", given value is of type "%s".';
24
25
    const WRONG_FORM_VALUE_OBJECT_TYPE = 'The form given in the argument `object` of `FormViewHelper` must be an instance of "%s", given value is an instance of "%s".';
26
27
    const WRONG_FORM_VALUE_CLASS_NAME = 'The form given in the argument `object` of `FormViewHelper` must be an instance of "%s", given value is an instance of "%s".';
28
29
    const WRONG_BACKEND_CACHE_TYPE = 'The cache class name given in configuration "config.tx_formz.settings.defaultBackendCache" must inherit "%s" (current value: "%s")';
30
31
    /**
32
     * @code 1457442462
33
     *
34
     * @param string $name
35
     * @return self
36
     */
37
    final public static function formViewHelperWrongFormType($name)
38
    {
39
        /** @var self $exception */
40
        $exception = self::getNewExceptionInstance(
41
            self::WRONG_FORM_TYPE,
42
            [FormInterface::class, $name]
43
        );
44
45
        return $exception;
46
    }
47
48
    /**
49
     * @code 1490713939
50
     *
51
     * @param mixed $value
52
     * @return self
53
     */
54
    final public static function formViewHelperWrongFormValueType($value)
55
    {
56
        /** @var self $exception */
57
        $exception = self::getNewExceptionInstance(
58
            self::WRONG_FORM_VALUE_TYPE,
59
            [FormInterface::class, gettype($value)]
60
        );
61
62
        return $exception;
63
    }
64
65
    /**
66
     * @code 1490714346
67
     *
68
     * @param object $value
69
     * @return self
70
     */
71
    final public static function formViewHelperWrongFormValueObjectType($value)
72
    {
73
        /** @var self $exception */
74
        $exception = self::getNewExceptionInstance(
75
            self::WRONG_FORM_VALUE_OBJECT_TYPE,
76
            [FormInterface::class, get_class($value)]
77
        );
78
79
        return $exception;
80
    }
81
82
    /**
83
     * @code 1490714534
84
     *
85
     * @param string $className
86
     * @param object $value
87
     * @return self
88
     */
89
    final public static function formViewHelperWrongFormValueClassName($className, $value)
90
    {
91
        /** @var self $exception */
92
        $exception = self::getNewExceptionInstance(
93
            self::WRONG_FORM_VALUE_CLASS_NAME,
94
            [$className, get_class($value)]
95
        );
96
97
        return $exception;
98
    }
99
100
    /**
101
     * @code 1459251263
102
     *
103
     * @param string $className
104
     * @return self
105
     */
106
    final public static function wrongBackendCacheType($className)
107
    {
108
        /** @var self $exception */
109
        $exception = self::getNewExceptionInstance(
110
            self::WRONG_BACKEND_CACHE_TYPE,
111
            [AbstractBackend::class, $className]
112
        );
113
114
        return $exception;
115
    }
116
}
117