errors)) { foreach ($body->errors AS $error) { if ($error->code === self::NOT_ENOUGH_CREDIT) { throw new Exceptions\BalanceException; } elseif ($error->code === self::REQUEST_NOT_ALLOWED) { throw new Exceptions\AuthenticateException; } $this->errors[] = $error; } } } /** * Get the error string to show in the Exception message. * * @return string */ public function getErrorString() { $errorString = array (); foreach ($this->errors AS $error) { $errorString[] = $error->description; } return implode(', ', $errorString); } }