public function getCodigoBarras()
{
if (!empty($this->campoCodigoBarras)) {
return $this->campoCodigoBarras;
}
if (!$this->isValid()) {
throw new \Exception('Campos requeridos pelo banco, aparentam estar ausentes');
}
$codigo = Util::numberFormatGeral($this->getCodigoBanco(), 3) . $this->getMoeda() . Util::fatorVencimento($this->getDataVencimento()) . Util::numberFormatValue($this->getValor(), 10, 0) . $this->getCampoLivre();
$resto = Util::modulo11($codigo, 2, 9, false);
$dv = in_array($resto, [0, 10, 11]) ? 1 : $resto;
return $this->campoCodigoBarras = substr($codigo, 0, 4) . $dv . substr($codigo, 4);
}