Conditions | 2 |
Paths | 2 |
Total Lines | 32 |
Code Lines | 16 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 6 |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
11 | public function call(string $uri, array $simulator): ?string |
||
12 | { |
||
13 | $params = [ |
||
14 | 'sessionId' => $simulator['session_id'], |
||
15 | 'networkCode' => $simulator['network_code'], |
||
16 | 'phoneNumber' => $simulator['phone_number'], |
||
17 | 'text' => $simulator['answers'], |
||
18 | 'serviceCode' => $simulator['service_code'], |
||
19 | ]; |
||
20 | |||
21 | // try { |
||
22 | $response = (new Client())->request('POST', $uri, [ |
||
23 | 'headers' => [ |
||
24 | 'Accept' => 'text/plain', |
||
25 | ], |
||
26 | 'form_params' => $params, |
||
27 | ]); |
||
28 | |||
29 | $body = (string) $response->getBody(); |
||
30 | |||
31 | $cmd = substr($body, 0, 3); |
||
32 | $payload = substr($body, 4); |
||
33 | // } catch (\Throwable $th) { |
||
34 | // $firstLine = preg_split('#\r?\n#', ltrim($th->getMessage()), 2)[0]; |
||
35 | // throw new \Exception($firstLine); |
||
36 | // } |
||
37 | |||
38 | if ('END' === $cmd) { |
||
39 | throw new FlowBreakException($payload); |
||
40 | } |
||
41 | |||
42 | return $payload; |
||
43 | } |
||
45 |