/** * @author nathanhelenihi * @group common */ public function testToArray() { $data = 'Bad data'; $obj = new MaError(MA_OTA_ERR_JSON_INVALID, $data); $errors = $obj->getMappings(); $this->assertSame($obj->toArray(), array('id' => MA_OTA_ERR_JSON_INVALID, 'type' => $errors[MA_OTA_ERR_JSON_INVALID]['type'], 'msg' => $errors[MA_OTA_ERR_JSON_INVALID]['msg'], 'data' => $data)); }
/** * Add an error to the response object. * * @param int $error The Error code. * @param string $msg Custom error message. * * @return \MyAllocator\phpsdkota\src\Object\MaResponse Response object. */ public function error($id, $data = null) { $this->success = false; $error = new \MyAllocator\phpsdkota\src\Object\MaError($id, $data); $this->log("Error", json_encode($error->toArray())); $this->errors[] = $error; return $this; }