@param BoletoContract $boleto

@return $this
@throws \Exception
762715
public function addBoleto(BoletoContract $boleto)
    {
        $this->boletos[] = $boleto;
        if (!$boleto->isComRegistro()) {
            return $this;
        }

        $this->iniciaDetalhe();

        $this->add(1, 1, '1');
        $this->add(2, 2, 'A');
        $this->add(3, 3, $this->getCarteiraNumero());
        $this->add(4, 4, 'A');
        $this->add(5, 16, '');
        $this->add(17, 17, 'A');
        $this->add(18, 18, 'A');
        $this->add(19, 19, 'A');
        $this->add(20, 47, '');
        $this->add(48, 56, Util::formatCnab('9', $boleto->getNossoNumero(), 9));
        $this->add(57, 62, '');
        $this->add(63, 70, Carbon::now()->format('Ymd'));
        $this->add(71, 71, '');
        $this->add(72, 72, $boleto->getByte() == 1 ? 'S' : 'N');
        $this->add(73, 73, '');
        $this->add(74, 74, $boleto->getByte() == 1 ? 'A' : 'B');
        $this->add(75, 76, '');
        $this->add(77, 78, '');
        $this->add(79, 82, '');
        $this->add(83, 92, Util::formatCnab('9', 0, 10, 2));
        $this->add(93, 96, Util::formatCnab('9', $boleto->getMulta(), 4, 2));
        $this->add(97, 108, '');
        $this->add(109, 110, self::OCORRENCIA_REMESSA); // REGISTRO
        if ($boleto->getStatus() == $boleto::STATUS_BAIXA) {
            $this->add(109, 110, self::OCORRENCIA_BAIXA); // BAIXA
        }
        if ($boleto->getStatus() == $boleto::STATUS_ALTERACAO) {
            $this->add(109, 110, self::OCORRENCIA_ALT_VENCIMENTO); // ALTERAR VENCIMENTO
        }
        if ($boleto->getStatus() == $boleto::STATUS_ALTERACAO_DATA) {
            $this->add(109, 110, self::OCORRENCIA_ALT_VENCIMENTO);
        }
        if ($boleto->getStatus() == $boleto::STATUS_CUSTOM) {
            $this->add(109, 110, sprintf('%2.02s', $boleto->getComando()));
        }
        $this->add(111, 120, Util::formatCnab('X', $boleto->getNumeroDocumento(), 10));
        $this->add(121, 126, $boleto->getDataVencimento()->format('dmy'));
        $this->add(127, 139, Util::formatCnab('9', $boleto->getValor(), 13, 2));
        $this->add(140, 148, '');
        $this->add(149, 149, $boleto->getEspecieDocCodigo('A'));
        $this->add(150, 150, $boleto->getAceite());
        $this->add(151, 156, $boleto->getDataDocumento()->format('dmy'));
        $this->add(157, 158, self::INSTRUCAO_SEM);
        $this->add(159, 160, self::INSTRUCAO_SEM);
        if ($boleto->getDiasProtesto() > 0) {
            $this->add(157, 158, self::INSTRUCAO_PROTESTO);
            $this->add(159, 160, Util::formatCnab('9', $boleto->getDiasProtesto(), 2));
        }
        $this->add(161, 173, Util::formatCnab('9', $boleto->getMoraDia(), 13, 2));
        $this->add(174, 179, $boleto->getDesconto() > 0 ? $boleto->getDataDesconto()->format('dmy') : '000000');
        $this->add(180, 192, Util::formatCnab('9', $boleto->getDesconto(), 13, 2));
        $this->add(193, 205, Util::formatCnab('9', 0, 13, 2));
        $this->add(206, 218, Util::formatCnab('9', 0, 13, 2));
        $this->add(219, 220, strlen(Util::onlyNumbers($boleto->getPagador()->getDocumento())) == 14 ? '20' : '10');
        $this->add(221, 234, Util::formatCnab('9L', $boleto->getPagador()->getDocumento(), 14));
        $this->add(235, 274, Util::formatCnab('X', $boleto->getPagador()->getNome(), 40));
        $this->add(275, 314, Util::formatCnab('X', $boleto->getPagador()->getEndereco(), 40));
        $this->add(315, 319, '00000');
        $this->add(320, 325, '000000');
        $this->add(326, 326, ' ');
        $this->add(327, 334, Util::formatCnab('9L', $boleto->getPagador()->getCep(), 8));
        $this->add(335, 339, '00000');
        $this->add(340, 353, $boleto->getSacadorAvalista() ? Util::formatCnab('9L', $boleto->getSacadorAvalista()->getDocumento(), 14) : Util::formatCnab('X', '', 14));
        $this->add(354, 394, Util::formatCnab('X', $boleto->getSacadorAvalista() ? $boleto->getSacadorAvalista()->getNome() : '', 41));
        $this->add(395, 400, Util::formatCnab('9', $this->iRegistros + 1, 6));

        if ($boleto->getByte() == 1) {
            $this->iniciaDetalhe();

            $this->add(1, 1, '2');
            $this->add(2, 12, '');
            $this->add(13, 21, Util::formatCnab('9', $boleto->getNossoNumero(), 9));
            $this->add(22, 101, Util::formatCnab('X', $boleto->getInstrucoes()[0], 80));
            $this->add(102, 181, Util::formatCnab('X', $boleto->getInstrucoes()[1], 80));
            $this->add(182, 261, Util::formatCnab('X', $boleto->getInstrucoes()[2], 80));
            $this->add(262, 341, Util::formatCnab('X', $boleto->getInstrucoes()[3], 80));
            $this->add(342, 351, Util::formatCnab('9', $boleto->getNumeroDocumento(), 10));
            $this->add(352, 394, '');
            $this->add(395, 400, Util::formatCnab('9', $this->iRegistros + 1, 6));
        }

        return $this;
    }
767782
public function setInitClosure(CLOSURE $initClosure = null) {
        if ($initClosure === null)
            throw new \Exception ("the initClosure must be set for Stepcontroller");
        $initClosure = $this->generateClosure($initClosure);
        $closureParameter = $this->standardClosureArguments();
        $initClosure($closureParameter);
    }
1357903
public function message(callable $predicate): self
    {
        assertThat(
                $this->actualException->getMessage(),
                new Wrap($predicate, 'exception message %s')
        );
        return $this;
    }
878136
public function setCountry($country)
    {
        $country = strtoupper($country);
        if (!Icepay_Parameter_Validation::country($country))
            throw new Exception('Country not valid');
        $this->data->ic_country = $country;
        return $this;
    }
883021
public function setContacts(array $contacts): SecurityTxt
    {
        if (!$this->validContacts($contacts, true)) {
            throw new Exception('Contacts array must contain well-formed e-mails and/or URLs.');
        }

        $this->contacts = $contacts;

        return $this;
    }
205887
public function build($valor, $numeroDocumento, \DateTime $vencimento)
    {
        $reflection = new ReflectionClass($this->namespace . '\\Boleto\\' . $this->type);

        $boleto = $reflection->newInstanceArgs(array($this->sacado, $this->cedente, $this->convenio));
        $boleto->setValorDocumento($valor)
            ->setNumeroDocumento($numeroDocumento)
            ->setDataVencimento($vencimento);

        return $boleto;
    }
1183928
public function setAttachments($attachments): self
    {
        if (!is_iterable($attachments)) {
            throw new Exception(sprintf('%s() expects argument passed to be iterable, %s given', __METHOD__, gettype($attachments)));
        }

        $this->attachments = [];
        foreach ($attachments as $attachment) {
            $this->addAttachment($attachment);
        }

        return $this;
    }
211641
public function setAttachment(string $attachment = "F") : CNabuDataObject
    {
        if ($attachment === null) {
            throw new ENabuCoreException(
                    ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN,
                    array("\$attachment")
            );
        }
        $this->setValue('nb_site_target_attachment', $attachment);
        
        return $this;
    }
1006490
function setIssuerException(/*callable*/ $callable)
    {
        if (!is_callable($callable))
            throw new \InvalidArgumentException(sprintf(
                'Issuer must be callable; given: (%s).'
                , \Poirot\Std\flatten($callable)
            ));
        
        $this->issuer_exception = $callable;
        return $this;
    }
90912
public function setRequestContact(bool $requestContact = null): self
    {
        $this->requestContact = $requestContact;

        if ($requestContact === true) {
            $this->requestLocation = null;
        }

        return $this;
    }
1358167
public function setBoleto(Boleto $boleto)
    {
        $boleto->setContext(Moip::PAYMENT);
        $this->data->fundingInstrument->method = self::METHOD_BOLETO;
        $this->data->fundingInstrument->boleto = $boleto->getData();

        return $this;
    }
139023
public function setDiasBaixaAutomatica($baixaAutomatica)
    {
        if ($this->getDiasProtesto() > 0) {
            throw new \Exception('Você deve usar dias de protesto ou dias de baixa, nunca os 2');
        }
        $baixaAutomatica = (int) $baixaAutomatica;
        $this->diasBaixaAutomatica = $baixaAutomatica > 0 ? $baixaAutomatica : 0;
        return $this;
    }
301069
public function setExclusionStrategy(ExclusionStrategyInterface $exclusionStrategy = null)
    {
        $this->cleanUpExclusionStrategies();
        if ($exclusionStrategy) {
            $this->addExclusionStrategy($exclusionStrategy);
        }

        return $this;
    }
1322970
public function execute()
    {
        try {
            $this->order = $this->loadOrder();
            /** @var \UOL\PagSeguro\Model\Direct\BoletoMethod $boleto */
            $boleto = new BoletoMethod(
                $this->_objectManager->create('Magento\Directory\Api\CountryInformationAcquirerInterface'),
                $this->_objectManager->create('Magento\Framework\App\Config\ScopeConfigInterface'),
                $this->_objectManager->create('Magento\Framework\Module\ModuleList'),
                $this->order,
                $this->_objectManager->create('UOL\PagSeguro\Helper\Library'),
                $data = [
                    'sender_document' => $this->helperData()->formatDocument($this->getRequest()->getParam('sender_document')),
                    'sender_hash' => $this->getRequest()->getParam('sender_hash'),
                    'order_id' => $this->lastRealOrderId()
                ]
            );
            return $this->placeOrder($boleto);
        } catch (\Exception $exception) {
            if (!is_null($this->order)) {
                $this->changeOrderHistory('pagseguro_cancelada');
            }
            $this->clearSession();
            return $this->whenError($exception->getMessage());
        }
    }
34867
public function setCatchAllSetter($setMethod)
    {
        if (method_exists($this->getEntityPrototype(), $setMethod) === false) {
            throw new Exception\ConfigFailed(sprintf($this->exceptions[2], $setMethod, $this->entityClassName), 2);
        }

        $this->catchAllSetter = $setMethod;

        return $this;
    }
1325425
protected function segmentoP(BoletoContract $boleto)
    {
        $this->iniciaDetalhe();
        $this->add(1, 3, Util::onlyNumbers($this->getCodigoBanco()));
        $this->add(4, 7, '0001');
        $this->add(8, 8, '3');
        $this->add(9, 13, Util::formatCnab('9', $this->iRegistrosLote, 5));
        $this->add(14, 14, 'P');
        $this->add(15, 15, '');
        $this->add(16, 17, self::OCORRENCIA_REMESSA);
        if ($boleto->getStatus() == $boleto::STATUS_BAIXA) {
            $this->add(16, 17, self::OCORRENCIA_PEDIDO_BAIXA);
        }
        if ($boleto->getStatus() == $boleto::STATUS_ALTERACAO) {
            $this->add(16, 17, self::OCORRENCIA_ALT_OUTROS_DADOS);
        }
        $this->add(18, 22, Util::formatCnab('9', $this->getAgencia(), 5));
        $this->add(23, 23, CalculoDV::cefAgencia($this->getAgencia()));
        $this->add(24, 29, Util::formatCnab('9', $this->getCodigoCliente(), 6));
        $this->add(30, 37, '00000000');
        $this->add(38, 39, '00');
        $this->add(40, 57, Util::formatCnab('9', $boleto->getNossoNumero(), 18));
        $this->add(58, 58, '1'); //'1' = Cobrança Simples
        $this->add(59, 59, '1'); //'1' - Cobrança Registrada
        $this->add(60, 60, '2'); //'2’ - Escritural
        $this->add(61, 61, '2'); //‘2’ = Cliente Emite
        $this->add(62, 62, '0'); //‘0’ = Postagem pelo Beneficiário
        $this->add(63, 73, Util::formatCnab('X', $boleto->getNumeroDocumento(), 11));
        $this->add(74, 77, '');
        $this->add(78, 85, $boleto->getDataVencimento()->format('dmY'));
        $this->add(86, 100, Util::formatCnab('9', $boleto->getValor(), 15, 2));
        $this->add(101, 105, '00000');
        $this->add(106, 106, '0');
        $this->add(107, 108, Util::formatCnab('9', $boleto->getEspecieDocCodigo(), 2));
        $this->add(109, 109, Util::formatCnab('9', $boleto->getAceite(), 1));
        $this->add(110, 117, $boleto->getDataDocumento()->format('dmY'));
        $this->add(118, 118, $boleto->getJuros() ? '2' : '3'); //'2' = Percentual Mensal '3' = Isento
        $this->add(119, 126, $boleto->getDataVencimento()->addDays(1)->format('dmY'));
        $this->add(127, 141, Util::formatCnab('9', $boleto->getJuros(), 15, 2)); //Taxa mensal
        $this->add(142, 142, $boleto->getDesconto() > 0 ? '1' : '0'); // 0 = Sem Desconto, 1 = Valor Fixo até a data informada, 2 = Percentual até a data informada
        $this->add(143, 150, $boleto->getDesconto() > 0 ? $boleto->getDataDesconto()->format('dmY') : '00000000');
        $this->add(151, 165, Util::formatCnab('9', $boleto->getDesconto(), 15, 2));
        $this->add(166, 180, Util::formatCnab('9', 0, 15, 2));
        $this->add(181, 195, Util::formatCnab('9', 0, 15, 2));
        $this->add(196, 220, Util::formatCnab('X', $boleto->getNumeroDocumento(), 25));
        $this->add(221, 221, self::PROTESTO_SEM);
        if ($boleto->getDiasProtesto() > 0) {
            $this->add(221, 221, self::PROTESTO_DIAS_UTEIS);
        }
        $this->add(222, 223, Util::formatCnab('9', $boleto->getDiasProtesto(), 2));
        $this->add(224, 224, $boleto->getDiasProtesto() > 0 ? '2' : '1'); // '1' = Baixar/Devolver / 2' = Não Baixar / Não Devolver (NÃO TRATADO PELO BANCO)
        $this->add(225, 227, Util::formatCnab('9', $boleto->getDiasBaixaAutomatica(), 3));  //Se informado 000 será baixado no dia posterior do vencimento. Se for informado '' será baixado 5 dias após o vencimento, se não será baixado os dias informados
        $this->add(228, 229, Util::formatCnab('9', $boleto->getMoeda(), 2));
        $this->add(230, 239, '0000000000');
        $this->add(240, 240, '');

        return $this;
    }
1145086
public function setDisclosure(string $disclosure): SecurityTxt
    {
        if (!$this->validDisclosure($disclosure)) {
            throw new Exception('Disclosure policy must be either "full", "partial", or "none".');
        }

        $this->disclosure = $disclosure;

        return $this;
    }