Skip to content

Commit f9ea099

Browse files
committed
Scrutinizer report response
1 parent 28c50f2 commit f9ea099

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

src/EchoIt/JsonApi/Exception/Validation.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class Validation extends Exception
2020
* @param string $message The Exception message to throw
2121
* @param int $code The Exception code
2222
* @param int $httpStatusCode HTTP status code which can be used for broken request
23-
* @param Illuminate\Support\MessageBag $errors Validation errors
23+
* @param Illuminate\Support\MessageBag $messages Validation errors
2424
*/
2525
public function __construct($message = '', $code = 0, $httpStatusCode = 500, ValidationMessages $messages = NULL)
2626
{
@@ -33,7 +33,7 @@ public function __construct($message = '', $code = 0, $httpStatusCode = 500, Val
3333
/**
3434
* This method returns a HTTP response representation of the Exception
3535
*
36-
* @return JsonApi\ErrorResponse
36+
* @return JsonApi\MultiErrorResponse
3737
*/
3838
public function response()
3939
{

src/EchoIt/JsonApi/Model.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ public function getResourceType()
127127
*
128128
* @param Array $values user passed values (request data)
129129
*
130-
* @return true|Illuminate\Support\MessageBag True on pass, MessageBag of errors on fail
130+
* @return bool|Illuminate\Support\MessageBag True on pass, MessageBag of errors on fail
131131
*/
132132
public function validateArray(Array $values)
133133
{

src/EchoIt/JsonApi/MultiErrorResponse.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,16 @@ public function __construct($httpStatusCode, $errorCode, $errorTitle, Validation
2222
{
2323
$data = [ 'errors' => [] ];
2424

25-
foreach ($errors->keys() as $field) {
25+
if ($errors) {
26+
foreach ($errors->keys() as $field) {
2627

27-
foreach ($errors->get($field) as $message) {
28+
foreach ($errors->get($field) as $message) {
2829

29-
$data['errors'][] = [ 'status' => $httpStatusCode, 'code' => $errorCode, 'title' => 'Validation Fail', 'detail' => $message, 'meta' => ['field' => $field] ];
30+
$data['errors'][] = [ 'status' => $httpStatusCode, 'code' => $errorCode, 'title' => 'Validation Fail', 'detail' => $message, 'meta' => ['field' => $field] ];
3031

31-
}
32+
}
3233

34+
}
3335
}
3436

3537
parent::__construct($data, $httpStatusCode);

0 commit comments

Comments
 (0)