Cronario\AbstractJob::setResult PHP Method

setResult() public method

public setResult ( $result, null $data = null ) : ResultException | mixed
$result
$data null
return Cronario\Exception\ResultException | mixed
    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;
    }