Conditions | 5 |
Paths | 9 |
Total Lines | 24 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 30 |
Changes | 0 |
1 | <?php |
||
27 | public function normalize(JsonRpcCallResponse $jsonRpcCallResponse) |
||
28 | { |
||
29 | $resultList = []; |
||
30 | foreach ($jsonRpcCallResponse->getResponseList() as $response) { |
||
31 | // Notifications must not have a response, even if they are on error |
||
32 | if (!$response->isNotification()) { |
||
33 | $resultList[] = $this->responseNormalizer->normalize($response); |
||
34 | } |
||
35 | } |
||
36 | |||
37 | // if no result, it means It was either : |
||
38 | // - a batch call with only notifications |
||
39 | // - a notification request |
||
40 | // => return null response in all cases |
||
41 | if (0 === count($resultList)) { |
||
42 | return null; |
||
43 | } |
||
44 | |||
45 | // In case it's not a batch, return the first (lonely) result |
||
46 | if (!$jsonRpcCallResponse->isBatch()) { |
||
47 | return array_shift($resultList); |
||
48 | } |
||
49 | |||
50 | return $resultList; |
||
51 | } |
||
53 |