Skip to content

Commit f147fdd

Browse files
authored
Merge pull request #42 from Daemant/master
2 parents e287b7c + cca504d commit f147fdd

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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+
}

src/Transformer/ElementTransformer.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
namespace MultiTheftAuto\Sdk\Transformer;
1616

17+
use MultiTheftAuto\Sdk\Exception\NotCallableResourceException;
1718
use MultiTheftAuto\Sdk\Factory\ElementFactory;
1819

1920
abstract class ElementTransformer
@@ -29,6 +30,10 @@ public static function fromServer(?string $dataFromServer): ?array
2930

3031
$data = json_decode($dataFromServer);
3132

33+
if ($data === null) {
34+
throw new NotCallableResourceException();
35+
}
36+
3237
foreach ($data as &$value) {
3338
ElementTransformer::stringValuesToObjects($value);
3439
}

0 commit comments

Comments
 (0)