| Conditions | 5 |
| Paths | 5 |
| Total Lines | 15 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 1 | Features | 1 |
| 1 | <?php |
||
| 19 | public static function createFromResponse(ResponseInterface $response) |
||
| 20 | { |
||
| 21 | $errorDescription = json_decode($response->getBody()->getContents(), true)['errorDescription'] ?? 'Unknown error'; |
||
| 22 | |||
| 23 | switch ($errorDescription) { |
||
| 24 | case self::INVALID_ACCOUNT: |
||
| 25 | return new InvalidAccountException($errorDescription); |
||
| 26 | case self::UNKNOWN_TOKEN: |
||
| 27 | return new UnknownTokenException($errorDescription); |
||
| 28 | case self::TOO_MANY_REQUESTS: |
||
| 29 | return new TooManyRequestsException($errorDescription); |
||
| 30 | case self::INTERNAL_ERROR: |
||
| 31 | return new InternalErrorException($errorDescription); |
||
| 32 | default: |
||
| 33 | return new MonobankException($errorDescription); |
||
| 34 | } |
||
| 37 |