Inheritance: extends Ik\Lib\Exception\ResultException
Ejemplo n.º 1
0
 /**
  * @param      $result
  * @param null $data
  *
  * @return ResultException|mixed
  * @throws \Result\RuntimeException
  */
 public function setResult($result, $data = null)
 {
     if (null === $result) {
         return $this;
     }
     if (is_numeric($result)) {
         if ($result > 1000) {
             $result = ResultException::factory($result, $data);
         } else {
             $result = new static::$resultClass((int) $result, $data);
         }
     } elseif ($result instanceof ResultException) {
         // continue
     } elseif (is_array($result) && isset($result[self::RESULT_P_GLOBAL_CODE])) {
         $result = ResultException::factory($result[self::RESULT_P_GLOBAL_CODE], $result[self::RESULT_P_DATA]);
     } else {
         $result = new ResultException(ResultException::E_INTERNAL, $result);
     }
     if (!empty($data)) {
         $result->addData($data);
     }
     $this->result = $result;
     $this->setData(self::P_RESULT, [self::RESULT_P_GLOBAL_CODE => $result->getGlobalCode(), self::RESULT_P_DATA => $result->getData()]);
     return $this;
 }
Ejemplo n.º 2
0
 /**
  * @param      $result
  * @param null $data
  *
  * @return ResultException|mixed
  * @throws \Ik\Lib\Exception\RuntimeException
  */
 public function setResult($result, $data = null)
 {
     if (is_numeric($result)) {
         if ($result > 1000) {
             $result = ResultException::factory($result, $data);
         } else {
             $result = new static::$resultClass((int) $result, $data);
         }
     } elseif ($result instanceof ResultException) {
         // continue
     } else {
         $result = new ResultException(ResultException::E_INTERNAL, $result);
     }
     if (!empty($data)) {
         $result->addData($data);
     }
     $result->addData(['@' . self::P_IS_SYNC => $this->isSync(), '@' . self::P_ID => $this->getId(), '@' . self::P_APP_ID => $this->getAppId()]);
     $this->result = $result;
     return $this;
 }