Apply PSR-12 code style (#3886)
[GitHub/WoltLab/WCF.git] / wcfsetup / install / files / lib / system / exception / UserInputException.class.php
1 <?php
2
3 namespace wcf\system\exception;
4
5 /**
6 * UserInputException handles all formular input errors.
7 *
8 * @author Marcel Werk
9 * @copyright 2001-2019 WoltLab GmbH
10 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
11 * @package WoltLabSuite\Core\System\Exception
12 */
13 class UserInputException extends UserException
14 {
15 /**
16 * name of error field
17 * @var string
18 */
19 protected $field;
20
21 /**
22 * error type
23 * @var string
24 */
25 protected $type;
26
27 /**
28 * variables for AJAX error handling
29 * @var array
30 */
31 protected $variables = [];
32
33 /**
34 * Creates a new UserInputException.
35 *
36 * @param string $field affected formular field
37 * @param string $type kind of this error
38 * @param array $variables additional variables for AJAX error handling
39 */
40 public function __construct($field = '', $type = 'empty', array $variables = [])
41 {
42 $this->field = $field;
43 $this->type = $type;
44 $this->variables = $variables;
45 $this->message = 'Parameter ' . $field . ' is missing or invalid';
46
47 parent::__construct();
48 }
49
50 /**
51 * Returns the affected formular field of this error.
52 *
53 * @return string
54 */
55 public function getField()
56 {
57 return $this->field;
58 }
59
60 /**
61 * Returns the kind of this error.
62 *
63 * @return string
64 */
65 public function getType()
66 {
67 return $this->type;
68 }
69
70 /**
71 * Returns additional variables for AJAX error handling.
72 *
73 * @return array
74 */
75 public function getVariables()
76 {
77 return $this->variables;
78 }
79 }