public function gerar()
{
if (!$this->isValid()) {
throw new \Exception('Campos requeridos pelo banco, aparentam estar ausentes');
}
$stringRemessa = '';
if ($this->iRegistros < 1) {
throw new \Exception('Nenhuma linha detalhe foi adicionada');
}
$this->header();
$stringRemessa .= $this->valida($this->getHeader()) . $this->fimLinha;
foreach ($this->getDetalhes() as $i => $detalhe) {
$stringRemessa .= $this->valida($detalhe) . $this->fimLinha;
}
$this->trailer();
$stringRemessa .= $this->valida($this->getTrailer());
$stringRemessa .= $this->fimArquivo;
return $stringRemessa;
}