/**
* Retorna o array.
*
* @return array
*/
public function toArray()
{
$array = ['header' => $this->header->toArray(), 'headerLote' => $this->headerLote->toArray(), 'trailerLote' => $this->trailerLote->toArray(), 'trailer' => $this->trailer->toArray(), 'detalhes' => new Collection()];
foreach ($this->detalhe as $detalhe) {
$arr = ['ocorrenciaTipo' => $detalhe->getOcorrenciaTipo(), 'ocorrenciaDescricao' => $detalhe->getOcorrenciaDescricao(), 'segmentoT' => $detalhe->getSegmentoT()->toArray(), 'segmentoU' => $detalhe->getSegmentoU()->toArray(), 'segmentoY' => $detalhe->getSegmentoY()->toArray()];
if ($detalhe->getOcorrenciaTipo() == 9) {
$arr['error'] = ['message' => $detalhe->getError(), 'code' => $detalhe->getErrorCode()];
}
$array['detalhes']->add($arr);
}
return $array;
}