/** * @param AbstractModel|AbstractModel[]|\SoapFault $result * @throws InvalidArgument * @return $this; */ public function setResult($result) { if ($result instanceof \SoapFault) { $this->setIsSoapFault(true); $this->setErrorCode($result->getCode()); $this->setErrorMsg(SoapClientFactory::convertEncoding($result->getMessage())); $this->result = null; $this->setSoapFault($result); } else { $piece = $result; if (is_array($result)) { if (count($result)) { $piece = reset($result); } else { $piece = null; } } if ($piece !== null && !$piece instanceof AbstractModel && !$piece instanceof \SoapFault) { throw new InvalidArgument('O resultado deve ser uma instância de PhpSigep\\Model\\AbstractModel ou um ' . 'array de PhpSigep\\Model\\AbstractModel ou uma instância de \\SoapFault.'); } $this->result = $result; } return $this; }