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