1
1
<?php
2
-
2
+ /**
3
+ * MIT License
4
+ *
5
+ * Copyright (c) 2018 Dogan Ucar, <dogan@dogan-ucar.de>
6
+ *
7
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ * of this software and associated documentation files (the "Software"), to deal
9
+ * in the Software without restriction, including without limitation the rights
10
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ * copies of the Software, and to permit persons to whom the Software is
12
+ * furnished to do so, subject to the following conditions:
13
+ *
14
+ * The above copyright notice and this permission notice shall be included in all
15
+ * copies or substantial portions of the Software.
16
+ *
17
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ * SOFTWARE.
24
+ */
3
25
4
26
namespace doganoo \PHPUtil \Service ;
5
27
28
+ use function filter_var ;
29
+ use function strlen ;
30
+ use const FILTER_VALIDATE_EMAIL ;
6
31
7
32
class User {
8
33
@@ -11,7 +36,7 @@ class User {
11
36
public const PASSWORD_VALIDATION_SECURE = 3 ;
12
37
13
38
public function validEmail (string $ email ): bool {
14
- return \ filter_var ($ email , \ FILTER_VALIDATE_EMAIL ) !== false ;
39
+ return filter_var ($ email , FILTER_VALIDATE_EMAIL ) !== false ;
15
40
}
16
41
17
42
public function validatePassword (string $ password , int $ mode = self ::PASSWORD_VALIDATION_SECURE ): bool {
@@ -26,7 +51,7 @@ public function validatePassword(string $password, int $mode = self::PASSWORD_VA
26
51
}
27
52
28
53
private function validatePasswordUnsafe (string $ password ): bool {
29
- return \ strlen ($ password ) >= 8 ;
54
+ return strlen ($ password ) >= 8 ;
30
55
}
31
56
32
57
private function validatePasswordBasic (string $ password ): bool {
@@ -40,4 +65,4 @@ private function validatePasswordSecure(string $password): bool {
40
65
return $ valid && ((bool ) preg_match ("(^(?=.*[a-z])(?=.*[A-Z])(?=.*\d).+$) " , $ password ));
41
66
}
42
67
43
- }
68
+ }
0 commit comments