| +--------------------------------------------------------------------------+ | Author: Aleksander Machniak | +--------------------------------------------------------------------------+ */ /** * API result wrapper */ class kolab_client_api_result { /** * @var array */ private $data = array(); private $error_code; private $error_str; /** * Class constructor. * * @param array $data Result data * @param int $error_code Error code * @param string $error_str Error message */ public function __construct($data = array(), $error_code = null, $error_str = null) { if (is_array($data) && isset($data['result'])) { $this->data = $data['result']; } $this->error_code = $error_code; $this->error_str = $error_str; } /** * Error code getter. * * @return int Error code */ public function get_error_code() { return $this->error_code; } /** * Error message getter. * * @return string Error message */ public function get_error_str() { return $this->error_str; } /** * Response data getter. * * @param string $name Response member name * * @return array|string Data member or complete response data (when $name is null) */ public function get($name = null) { if ($name !== null) { return isset($this->data[$name]) ? $this->data[$name] : null; } return $this->data; } }