File tree Expand file tree Collapse file tree 2 files changed +27
-2
lines changed
Expand file tree Collapse file tree 2 files changed +27
-2
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ /*****************************************************************************
4+ *
5+ * PROJECT: MTA PHP SDK
6+ * LICENSE: See LICENSE in the top level directory
7+ * FILE: NotCallableResourceException.php
8+ *
9+ * Multi Theft Auto is available from http://www.multitheftauto.com/
10+ *
11+ *****************************************************************************/
12+
13+ declare (strict_types=1 );
14+
15+ namespace MultiTheftAuto \Sdk \Exception ;
16+
17+ class NotCallableResourceException extends MessageException
18+ {
19+ protected const EXCEPTION_MESSAGE = 'There was a problem with the request. Ensure that the resource handling the call is running. ' ;
20+ }
Original file line number Diff line number Diff line change 1515namespace MultiTheftAuto \Sdk \Transformer ;
1616
1717use MultiTheftAuto \Sdk \Factory \ElementFactory ;
18+ use MultiTheftAuto \Sdk \Exception \NotCallableResourceException ;
1819
1920abstract class ElementTransformer
2021{
@@ -29,8 +30,12 @@ public static function fromServer(?string $dataFromServer): ?array
2930
3031 $ data = json_decode ($ dataFromServer );
3132
32- foreach ($ data as &$ value ) {
33- ElementTransformer::stringValuesToObjects ($ value );
33+ if ($ data !== NULL ) {
34+ foreach ($ data as &$ value ) {
35+ ElementTransformer::stringValuesToObjects ($ value );
36+ }
37+ } else {
38+ throw new NotCallableResourceException ();
3439 }
3540
3641 return $ data ;
You can’t perform that action at this time.
0 commit comments