@@ -27,7 +27,7 @@ public function __construct(ResponseInterface $response)
27
27
$ message = sprintf ('HTTP %d returned for URL "%s". ' , $ code , $ url );
28
28
29
29
$ httpCodeFound = false ;
30
- $ json = false ;
30
+ $ isJson = false ;
31
31
foreach (array_reverse ($ response ->getInfo ('raw_headers ' )) as $ h ) {
32
32
if (0 === strpos ($ h , 'HTTP/ ' )) {
33
33
if ($ httpCodeFound ) {
@@ -40,7 +40,7 @@ public function __construct(ResponseInterface $response)
40
40
41
41
if (0 === stripos ($ h , 'content-type: ' )) {
42
42
if (preg_match ('/\bjson\b/i ' , $ h )) {
43
- $ json = true ;
43
+ $ isJson = true ;
44
44
}
45
45
46
46
if ($ httpCodeFound ) {
@@ -52,15 +52,15 @@ public function __construct(ResponseInterface $response)
52
52
// Try to guess a better error message using common API error formats
53
53
// The MIME type isn't explicitly checked because some formats inherit from others
54
54
// Ex: JSON:API follows RFC 7807 semantics, Hydra can be used in any JSON-LD-compatible format
55
- if ($ json && $ body = json_decode ($ response ->getContent (false ), true )) {
55
+ if ($ isJson && $ body = json_decode ($ response ->getContent (false ), true )) {
56
56
if (isset ($ body ['hydra:title ' ]) || isset ($ body ['hydra:description ' ])) {
57
57
// see http://www.hydra-cg.com/spec/latest/core/#description-of-http-status-codes-and-errors
58
- $ sep = isset ($ body ['hydra:title ' ], $ body ['hydra:description ' ]) ? "\n\n" : '' ;
59
- $ message = ($ body ['hydra:title ' ] ?? '' ).$ sep .($ body ['hydra:description ' ] ?? '' );
58
+ $ separator = isset ($ body ['hydra:title ' ], $ body ['hydra:description ' ]) ? "\n\n" : '' ;
59
+ $ message = ($ body ['hydra:title ' ] ?? '' ).$ separator .($ body ['hydra:description ' ] ?? '' );
60
60
} elseif (isset ($ body ['title ' ]) || isset ($ body ['detail ' ])) {
61
61
// see RFC 7807 and https://jsonapi.org/format/#error-objects
62
- $ sep = isset ($ body ['title ' ], $ body ['detail ' ]) ? "\n\n" : '' ;
63
- $ message = ($ body ['title ' ] ?? '' ).$ sep .($ body ['detail ' ] ?? '' );
62
+ $ separator = isset ($ body ['title ' ], $ body ['detail ' ]) ? "\n\n" : '' ;
63
+ $ message = ($ body ['title ' ] ?? '' ).$ separator .($ body ['detail ' ] ?? '' );
64
64
}
65
65
}
66
66
0 commit comments