Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
50.00% |
2 / 4 |
|
50.00% |
2 / 4 |
CRAP | |
0.00% |
0 / 1 |
| tao_helpers_form_Validator | |
50.00% |
2 / 4 |
|
50.00% |
2 / 4 |
8.12 | |
0.00% |
0 / 1 |
| getName | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getMessage | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
6 | |||
| setMessage | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getDefaultMessage | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| evaluate | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
| 1 | <?php |
| 2 | |
| 3 | use oat\oatbox\validator\ValidatorInterface; |
| 4 | use oat\oatbox\Configurable; |
| 5 | |
| 6 | /** |
| 7 | * This program is free software; you can redistribute it and/or |
| 8 | * modify it under the terms of the GNU General Public License |
| 9 | * as published by the Free Software Foundation; under version 2 |
| 10 | * of the License (non-upgradable). |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | * GNU General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License |
| 18 | * along with this program; if not, write to the Free Software |
| 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 20 | * |
| 21 | * Copyright (c) 2008-2010 (original work) Deutsche Institut für Internationale Pädagogische Forschung |
| 22 | * (under the project TAO-TRANSFER); |
| 23 | * 2009-2012 (update and modification) Public Research Centre Henri Tudor |
| 24 | * (under the project TAO-SUSTAIN & TAO-DEV); |
| 25 | * 2016 (update and modification) Open Assessment Technologies SA; |
| 26 | * |
| 27 | */ |
| 28 | |
| 29 | /** |
| 30 | * The validators enable you to perform a validation callback on a form element. |
| 31 | * It's provide a model of validation and must be overridden. |
| 32 | * |
| 33 | * @abstract |
| 34 | * @access public |
| 35 | * @author Joel Bout, <joel.bout@tudor.lu> |
| 36 | * @package tao |
| 37 | |
| 38 | */ |
| 39 | abstract class tao_helpers_form_Validator extends Configurable implements ValidatorInterface |
| 40 | { |
| 41 | /** |
| 42 | * Message to the user |
| 43 | * |
| 44 | * @access protected |
| 45 | * @var string |
| 46 | */ |
| 47 | protected $message = null; |
| 48 | |
| 49 | // --- OPERATIONS --- |
| 50 | |
| 51 | /** |
| 52 | * Short description of method getName |
| 53 | * |
| 54 | * @access public |
| 55 | * @author Joel Bout, <joel.bout@tudor.lu> |
| 56 | * @return string |
| 57 | */ |
| 58 | public function getName() |
| 59 | { |
| 60 | return (string) str_replace('tao_helpers_form_validators_', '', get_class($this)); |
| 61 | } |
| 62 | |
| 63 | /** |
| 64 | * Short description of method getMessage |
| 65 | * |
| 66 | * @access public |
| 67 | * @author Joel Bout, <joel.bout@tudor.lu> |
| 68 | * @return string |
| 69 | */ |
| 70 | public function getMessage() |
| 71 | { |
| 72 | return is_null($this->message) ? $this->getDefaultMessage() : $this->message; |
| 73 | } |
| 74 | |
| 75 | /** |
| 76 | * Short description of method getMessage |
| 77 | * |
| 78 | * @access public |
| 79 | * @author Joel Bout, <joel.bout@tudor.lu> |
| 80 | * @return string |
| 81 | */ |
| 82 | public function setMessage($message) |
| 83 | { |
| 84 | $this->message = $message; |
| 85 | } |
| 86 | |
| 87 | /** |
| 88 | * @return string |
| 89 | */ |
| 90 | protected function getDefaultMessage() |
| 91 | { |
| 92 | return __(''); |
| 93 | } |
| 94 | |
| 95 | /** |
| 96 | * Short description of method evaluate |
| 97 | * |
| 98 | * @abstract |
| 99 | * @access public |
| 100 | * @author Joel Bout, <joel.bout@tudor.lu> |
| 101 | * @param values |
| 102 | * @return boolean |
| 103 | */ |
| 104 | abstract public function evaluate($values); |
| 105 | } |