1 | <?php namespace Rocket\UI\Forms\ValidatorAdapters; |
||
5 | class LaravelValidator implements ValidatorInterface |
||
6 | { |
||
7 | /** |
||
8 | * @var Validator |
||
9 | */ |
||
10 | protected $validator; |
||
11 | protected $data; |
||
12 | protected $defaults; |
||
13 | |||
14 | /** |
||
15 | * @var \Illuminate\Session\Store |
||
16 | */ |
||
17 | protected $session; |
||
18 | |||
19 | /** |
||
20 | * {@inheritdoc} |
||
21 | */ |
||
22 | public function __construct($validator, $data, $defaults) |
||
28 | |||
29 | /** |
||
30 | * @return \Illuminate\Session\Store |
||
31 | */ |
||
32 | protected function getSession() |
||
41 | |||
42 | /** |
||
43 | * {@inheritdoc} |
||
44 | */ |
||
45 | public function hasError($name) |
||
55 | |||
56 | /** |
||
57 | * {@inheritdoc} |
||
58 | */ |
||
59 | public function getErrors($name) |
||
73 | |||
74 | /** |
||
75 | * Transform key from array to dot syntax. |
||
76 | * |
||
77 | * @param string $key |
||
78 | * |
||
79 | * @return string |
||
80 | */ |
||
81 | protected function transformKey($key) |
||
85 | |||
86 | /** |
||
87 | * Get the current value. |
||
88 | * |
||
89 | * With the following priority: |
||
90 | * 1. If the field was posted, take that value |
||
91 | * 2. If there is a model that has a value, take it |
||
92 | * 3. If there is a value defined when showing the field |
||
93 | * 4. If there is a default set in the validator |
||
94 | * |
||
95 | * @param string $name |
||
96 | * @param string $default |
||
97 | * @return mixed |
||
98 | */ |
||
99 | public function getValue($name, $default = '') |
||
124 | |||
125 | /** |
||
126 | * {@inheritdoc} |
||
127 | */ |
||
128 | public function isRequired($name) |
||
138 | |||
139 | /** |
||
140 | * {@inheritdoc} |
||
141 | */ |
||
142 | public static function supports($object) |
||
146 | } |
||
147 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: