Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 6 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
| common_exception_ValidationFailed | |
0.00% |
0 / 6 |
|
0.00% |
0 / 3 |
20 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
6 | |||
| getField | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getUserMessage | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 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) 2013 (original work) Open Assessment Technologies SA (under the project TAO-PRODUCT); |
| 19 | * |
| 20 | * |
| 21 | * Content type accepted can't be satisfied |
| 22 | * @access public |
| 23 | * @author Gyula Szucs, <gyula@taotesting.com> |
| 24 | * @package generis |
| 25 | */ |
| 26 | class common_exception_ValidationFailed extends common_exception_BadRequest |
| 27 | { |
| 28 | /** |
| 29 | * Name of the failed field. |
| 30 | * |
| 31 | * @var string |
| 32 | */ |
| 33 | private $field; |
| 34 | |
| 35 | /** |
| 36 | * common_exception_ValidationFailed constructor. |
| 37 | * |
| 38 | * @param string $field |
| 39 | * @param string|null $message |
| 40 | * @param int $code |
| 41 | */ |
| 42 | public function __construct($field, $message = null, $code = 0) |
| 43 | { |
| 44 | $this->field = $field; |
| 45 | |
| 46 | if (!$message) { |
| 47 | $message = sprintf("Validation for field '%s' has failed.", $field); |
| 48 | } |
| 49 | |
| 50 | parent::__construct($message, $code); |
| 51 | } |
| 52 | |
| 53 | /** |
| 54 | * @return string |
| 55 | */ |
| 56 | public function getField() |
| 57 | { |
| 58 | return $this->field; |
| 59 | } |
| 60 | |
| 61 | /** |
| 62 | * @return string |
| 63 | */ |
| 64 | public function getUserMessage() |
| 65 | { |
| 66 | return __("Validation for field '%s' has failed.", $this->field); |
| 67 | } |
| 68 | } |