| Conditions | 2 |
| Paths | 2 |
| Total Lines | 13 |
| Code Lines | 7 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 7 |
| CRAP Score | 2.0078 |
| Changes | 0 | ||
| 1 | <?php |
||
| 11 | 8 | public function __construct(HttpResponseInterface $response) |
|
| 12 | { |
||
| 13 | 8 | parent::__construct($response); |
|
| 14 | 8 | $content = $response->getBody()->getContents(); |
|
| 15 | // The API returns hidden Byte Order Mark characters, causing the |
||
| 16 | // JSON decoding to fail. |
||
| 17 | 8 | $content = preg_replace('/[\x00-\x1F\x80-\xFF]/', '', $content); |
|
| 18 | 8 | $content = json_decode($content); |
|
| 19 | |||
| 20 | 8 | if (json_last_error() !== JSON_ERROR_NONE) { |
|
| 21 | throw new AuthNetException(sprintf("JSON returned from API was not decoded: %s", json_last_error_msg())); |
||
| 22 | } |
||
| 23 | 8 | $this->contents = $content; |
|
| 24 | 8 | } |
|
| 26 |