MediaWiki REL1_34
ValidationException.php
Go to the documentation of this file.
1<?php
2
4
5use Exception;
6use Throwable;
7use UnexpectedValueException;
8
15class ValidationException extends UnexpectedValueException {
16
18 protected $paramName;
19
21 protected $paramValue;
22
24 protected $settings;
25
27 protected $failureCode;
28
30 protected $failureData;
31
41 public function __construct( $name, $value, $settings, $code, $data, $previous = null ) {
42 parent::__construct( self::formatMessage( $name, $code, $data ), 0, $previous );
43
44 $this->paramName = $name;
45 $this->paramValue = $value;
46 $this->settings = $settings;
47 $this->failureCode = $code;
48 $this->failureData = $data;
49 }
50
58 private static function formatMessage( $name, $code, $data ) {
59 $ret = "Validation of `$name` failed: $code";
60 foreach ( $data as $k => $v ) {
61 if ( is_array( $v ) ) {
62 $v = implode( ', ', $v );
63 }
64 $ret .= "; $k => $v";
65 }
66 return $ret;
67 }
68
73 public function getParamName() {
74 return $this->paramName;
75 }
76
81 public function getParamValue() {
82 return $this->paramValue;
83 }
84
89 public function getSettings() {
90 return $this->settings;
91 }
92
104 public function getFailureCode() {
105 return $this->failureCode;
106 }
107
125 public function getFailureData() {
126 return $this->failureData;
127 }
128
129}
getParamValue()
Fetch the parameter value that failed validation.
getSettings()
Fetch the settings array that failed validation.
getFailureData()
Fetch the validation failure data.
__construct( $name, $value, $settings, $code, $data, $previous=null)
static formatMessage( $name, $code, $data)
Make a simple English message for the exception.
getFailureCode()
Fetch the validation failure code.
getParamName()
Fetch the parameter name that failed validation.