InvalidOptionValueException   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 93
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 1
dl 0
loc 93
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A formViewHelperWrongFormType() 0 11 1
A formViewHelperWrongFormValueType() 0 11 1
A formViewHelperWrongFormValueObjectType() 0 11 1
A formViewHelperWrongFormValueClassName() 0 11 1
A wrongBackendCacheType() 0 11 1
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
     * @param string $name
33
     * @return self
34
     */
35
    final public static function formViewHelperWrongFormType($name)
36
    {
37
        /** @var self $exception */
38
        $exception = self::getNewExceptionInstance(
39
            self::WRONG_FORM_TYPE,
40
            1457442462,
41
            [FormInterface::class, $name]
42
        );
43
44
        return $exception;
45
    }
46
47
    /**
48
     * @param mixed $value
49
     * @return self
50
     */
51
    final public static function formViewHelperWrongFormValueType($value)
52
    {
53
        /** @var self $exception */
54
        $exception = self::getNewExceptionInstance(
55
            self::WRONG_FORM_VALUE_TYPE,
56
            1490713939,
57
            [FormInterface::class, gettype($value)]
58
        );
59
60
        return $exception;
61
    }
62
63
    /**
64
     * @param object $value
65
     * @return self
66
     */
67
    final public static function formViewHelperWrongFormValueObjectType($value)
68
    {
69
        /** @var self $exception */
70
        $exception = self::getNewExceptionInstance(
71
            self::WRONG_FORM_VALUE_OBJECT_TYPE,
72
            1490714346,
73
            [FormInterface::class, get_class($value)]
74
        );
75
76
        return $exception;
77
    }
78
79
    /**
80
     * @param string $className
81
     * @param object $value
82
     * @return self
83
     */
84
    final public static function formViewHelperWrongFormValueClassName($className, $value)
85
    {
86
        /** @var self $exception */
87
        $exception = self::getNewExceptionInstance(
88
            self::WRONG_FORM_VALUE_CLASS_NAME,
89
            1490714534,
90
            [$className, get_class($value)]
91
        );
92
93
        return $exception;
94
    }
95
96
    /**
97
     * @param string $className
98
     * @return self
99
     */
100
    final public static function wrongBackendCacheType($className)
101
    {
102
        /** @var self $exception */
103
        $exception = self::getNewExceptionInstance(
104
            self::WRONG_BACKEND_CACHE_TYPE,
105
            1459251263,
106
            [AbstractBackend::class, $className]
107
        );
108
109
        return $exception;
110
    }
111
}
112