Conditions | 3 |
Paths | 4 |
Total Lines | 20 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 12 |
Changes | 2 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
17 | private function validates($user, $group) |
||
18 | { |
||
19 | $validationRules = array($group); |
||
20 | |||
21 | if (!is_null($user->getEmail())) { |
||
22 | $validationRules[] = 'with_email'; |
||
23 | } |
||
24 | |||
25 | if (!is_null($user->getPhoneNumber())) { |
||
26 | $validationRules[] = 'with_phone'; |
||
27 | } |
||
28 | |||
29 | $validator = $this->container->get('validator'); |
||
|
|||
30 | $errors = $validator->validate( |
||
31 | $user, |
||
32 | $validationRules |
||
33 | ); |
||
34 | |||
35 | return $errors; |
||
36 | } |
||
37 | } |
||
38 |
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: