@@ 21-28 (lines=8) @@ | ||
18 | public function sendFailedResponse(array $errors, int $statusCode) |
|
19 | { |
|
20 | $errorsJson = []; |
|
21 | if (!empty($errors['email'])) { |
|
22 | $emailError = [ |
|
23 | 'status' => $statusCode, |
|
24 | 'title' => 'Email error', |
|
25 | 'detail' => $errors['email'][0] |
|
26 | ]; |
|
27 | array_push($errorsJson, $emailError); |
|
28 | } |
|
29 | ||
30 | if (!empty($errors['password'])) { |
|
31 | $passwordError = [ |
|
@@ 30-37 (lines=8) @@ | ||
27 | array_push($errorsJson, $emailError); |
|
28 | } |
|
29 | ||
30 | if (!empty($errors['password'])) { |
|
31 | $passwordError = [ |
|
32 | 'status' => $statusCode, |
|
33 | 'title' => 'Password error', |
|
34 | 'detail' => $errors['password'][0] |
|
35 | ]; |
|
36 | array_push($errorsJson, $passwordError); |
|
37 | } |
|
38 | ||
39 | if (!empty($errors['password_confirmation'])) { |
|
40 | $passwordConfirmationError = [ |
|
@@ 39-46 (lines=8) @@ | ||
36 | array_push($errorsJson, $passwordError); |
|
37 | } |
|
38 | ||
39 | if (!empty($errors['password_confirmation'])) { |
|
40 | $passwordConfirmationError = [ |
|
41 | 'status' => $statusCode, |
|
42 | 'title' => 'Password error', |
|
43 | 'detail' => $errors['password_confirmation'][0] |
|
44 | ]; |
|
45 | array_push($errorsJson, $passwordConfirmationError); |
|
46 | } |
|
47 | ||
48 | if (!empty($errors['name'])) { |
|
49 | $nameError = [ |
|
@@ 48-55 (lines=8) @@ | ||
45 | array_push($errorsJson, $passwordConfirmationError); |
|
46 | } |
|
47 | ||
48 | if (!empty($errors['name'])) { |
|
49 | $nameError = [ |
|
50 | 'status' => $statusCode, |
|
51 | 'title' => 'Name error', |
|
52 | 'detail' => $errors['name'][0] |
|
53 | ]; |
|
54 | array_push($errorsJson, $nameError); |
|
55 | } |
|
56 | ||
57 | if (!empty($errors['token'])) { |
|
58 | $tokenError = [ |
|
@@ 57-64 (lines=8) @@ | ||
54 | array_push($errorsJson, $nameError); |
|
55 | } |
|
56 | ||
57 | if (!empty($errors['token'])) { |
|
58 | $tokenError = [ |
|
59 | 'status' => $statusCode, |
|
60 | 'title' => 'Token error', |
|
61 | 'detail' => $errors['token'] |
|
62 | ]; |
|
63 | array_push($errorsJson, $tokenError); |
|
64 | } |
|
65 | ||
66 | if (!empty($errors['token'])) { |
|
67 | $tokenError = [ |
|
@@ 66-73 (lines=8) @@ | ||
63 | array_push($errorsJson, $tokenError); |
|
64 | } |
|
65 | ||
66 | if (!empty($errors['token'])) { |
|
67 | $tokenError = [ |
|
68 | 'status' => $statusCode, |
|
69 | 'title' => 'Token error', |
|
70 | 'detail' => $errors['token'] |
|
71 | ]; |
|
72 | array_push($errorsJson, $tokenError); |
|
73 | } |
|
74 | ||
75 | if (!empty($errors['activation_hash'])) { |
|
76 | $activationHashError = [ |
|
@@ 75-82 (lines=8) @@ | ||
72 | array_push($errorsJson, $tokenError); |
|
73 | } |
|
74 | ||
75 | if (!empty($errors['activation_hash'])) { |
|
76 | $activationHashError = [ |
|
77 | 'status' => $statusCode, |
|
78 | 'title' => 'Activation hash error', |
|
79 | 'detail' => $errors['activation_hash'][0] |
|
80 | ]; |
|
81 | array_push($errorsJson, $activationHashError); |
|
82 | } |
|
83 | ||
84 | $errorsJson = ($errorsJson) ? $errorsJson : $errors; |
|
85 |