Completed
Push — feature/improve-form-definitio... ( 5df9ba...6ebf3c )
by Romain
02:15
created

SilentException   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 3
dl 0
loc 40
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A fieldHasNoActivation() 0 10 1
A validatorHasNoActivation() 0 10 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\ConfigurationObject\Exceptions\SilentExceptionInterface;
17
use Romm\Formz\Form\Definition\Field\Field;
18
use Romm\Formz\Form\Definition\Field\Validation\Validator;
19
20
class SilentException extends FormzException implements SilentExceptionInterface
21
{
22
    const FIELD_HAS_NO_ACTIVATION = 'The field "%s" does not have activation. Please use the function `%s::hasActivation()` before.';
23
24
    const VALIDATOR_HAS_NO_ACTIVATION = 'The validator "%s" does not have activation. Please use the function `%s::hasActivation()` before.';
25
26
    /**
27
     * @code 1494685913
28
     *
29
     * @param Field $field
30
     * @return self
31
     */
32
    final public static function fieldHasNoActivation(Field $field)
33
    {
34
        /** @var self $exception */
35
        $exception = self::getNewExceptionInstance(
36
            self::FIELD_HAS_NO_ACTIVATION,
37
            [$field->getName(), Field::class]
38
        );
39
40
        return $exception;
41
    }
42
43
    /**
44
     * @code 1494690671
45
     *
46
     * @param Validator $validator
47
     * @return self
48
     */
49
    final public static function validatorHasNoActivation(Validator $validator)
50
    {
51
        /** @var self $exception */
52
        $exception = self::getNewExceptionInstance(
53
            self::VALIDATOR_HAS_NO_ACTIVATION,
54
            [$validator->getName(), Validator::class]
55
        );
56
57
        return $exception;
58
    }
59
}
60