Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 11 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| tao_helpers_form_validators_IndexIdentifier | |
0.00% |
0 / 11 |
|
0.00% |
0 / 1 |
20 | |
0.00% |
0 / 1 |
| evaluate | |
0.00% |
0 / 11 |
|
0.00% |
0 / 1 |
20 | |||
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * This program is free software; you can redistribute it and/or |
| 5 | * modify it under the terms of the GNU General Public License |
| 6 | * as published by the Free Software Foundation; under version 2 |
| 7 | * of the License (non-upgradable). |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program; if not, write to the Free Software |
| 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 17 | * |
| 18 | * Copyright (c) 2008-2010 (original work) Deutsche Institut für Internationale Pädagogische Forschung |
| 19 | * (under the project TAO-TRANSFER); |
| 20 | * 2009-2012 (update and modification) Public Research Centre Henri Tudor |
| 21 | * (under the project TAO-SUSTAIN & TAO-DEV); |
| 22 | * |
| 23 | */ |
| 24 | |
| 25 | /** |
| 26 | * Validator to verify the identifiers of the property indexes |
| 27 | * |
| 28 | * @access public |
| 29 | * @author Joel Bout, <joel.bout@tudor.lu> |
| 30 | * @package tao |
| 31 | */ |
| 32 | class tao_helpers_form_validators_IndexIdentifier extends tao_helpers_form_Validator |
| 33 | { |
| 34 | /** |
| 35 | * evalute the identifier |
| 36 | * |
| 37 | * @access public |
| 38 | * @author Joel Bout, <joel.bout@tudor.lu> |
| 39 | * @param values |
| 40 | * @return boolean |
| 41 | */ |
| 42 | public function evaluate($values) |
| 43 | { |
| 44 | //evaluate identifier, starts with letter, contains letters, numbers and _, ends with letter, number |
| 45 | if (preg_match("/^[a-z]+[a-z_0-9]*$/", $values) === 1) { |
| 46 | return true; |
| 47 | } else { |
| 48 | if (!$this->hasOption('message')) { |
| 49 | $message = empty($values) |
| 50 | ? __('The index identifier should not be empty') |
| 51 | // phpcs:disable Generic.Files.LineLength |
| 52 | : __('"%s" is not a valid index identifier. It must start with a letter and contain letters, numbers or underscores only', $values) |
| 53 | // phpcs:enable Generic.Files.LineLength |
| 54 | ; |
| 55 | $this->setMessage($message); |
| 56 | } |
| 57 | } |
| 58 | return false; |
| 59 | } |
| 60 | } |