Adds a encrypted segment to the message.

@param SegmentInterface $segment
965984
protected function addEncryptedSegment(SegmentInterface $segment)
    {
        $this->encryptedSegmentsCount++;
        $this->encryptedSegments[] = $segment;
        $encodedData = $this->encryptionEnvelop->getEncodedData()->getData();
        $encodedData .= (string) $segment;
        $this->encryptionEnvelop->setEncodedData($encodedData);
    }
611762
protected function addDynamic($segment, $connector, $parameters, $index)
    {
        $bool = strtolower($connector);

        $this->where(Str::snake($segment), '=', $parameters[$index], $bool);
    }
628839
private function setBounds(&$segments) {
        for ($i = 0, $count = count($segments); $i < $count; ++$i) {
            if ($segments[$i]->optional && $i - 1 >= 0) {
                $optional = true;

                for ($j = $i + 1; $j < $count; ++$j) {
                    if (!$segments[$j]->optional) {
                        $optional = false;
                        break;
                    }
                }

                if ($optional) {
                    $segments[$i - 1]->preEnd = true;
                }
                else {
                    for (--$j, $jc = $i - 1; $j >= $jc; --$j) {
                        $segments[$j]->optional = false;
                    }
                }
            }

            if ($i + 1 == $count) {
                $segments[$i]->end = true;
            }
        }
    }
924896
public static function MakeNumberSegments($segments)
	{
		$NumberSegments = [];

		foreach ($segments as $segment)
		{
			$NumberSegments[] = new NumberSegment($segment);
		}

		return $NumberSegments;
	}
1285660
public function add(ElementInterface $element)
    {
        if ($element instanceof File) {
            $this->setAttribute('enctype', 'multipart/form-data');
        }
        return parent::add($element);
    }
210265
private function checkEmail(Segment $segment, $email)
    {
        $user = $this->usersRepository->findBy('email', $email);
        if (!$user) {
            return false;
        }
        return $segment->isIn('email', $email);
    }
1215727
public function segmentoQ(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, 'Q');
        $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);
        }
        if ($boleto->getStatus() == $boleto::STATUS_ALTERACAO_DATA) {
            $this->add(16, 17, self::OCORRENCIA_ALT_VENCIMENTO);
        }
        if ($boleto->getStatus() == $boleto::STATUS_CUSTOM) {
            $this->add(16, 17, sprintf('%2.02s', $boleto->getComando()));
        }
        $this->add(18, 18, strlen(Util::onlyNumbers($this->getBeneficiario()->getDocumento())) == 14 ? 2 : 1);
        $this->add(19, 33, Util::formatCnab('9', Util::onlyNumbers($this->getBeneficiario()->getDocumento()), 15));
        $this->add(34, 63, Util::formatCnab('X', $boleto->getPagador()->getNome(), 30));
        $this->add(64, 73, '');
        $this->add(74, 113, Util::formatCnab('X', $boleto->getPagador()->getEndereco(), 40));
        $this->add(114, 128, Util::formatCnab('X', $boleto->getPagador()->getBairro(), 15));
        $this->add(129, 133, Util::formatCnab('9', Util::onlyNumbers($boleto->getPagador()->getCep()), 5));
        $this->add(134, 136, Util::formatCnab('9', Util::onlyNumbers(substr($boleto->getPagador()->getCep(), 6, 9)), 3));
        $this->add(137, 151, Util::formatCnab('X', $boleto->getPagador()->getCidade(), 15));
        $this->add(152, 153, Util::formatCnab('X', $boleto->getPagador()->getUf(), 2));
        $this->add(154, 154, '0');
        $this->add(155, 169, '000000000000000');
        $this->add(170, 199, '');
        $this->add(200, 209, '');
        $this->add(210, 212, '000');
        $this->add(213, 240, '');

        if($boleto->getSacadorAvalista()) {
            $this->add(154, 154, strlen(Util::onlyNumbers($boleto->getSacadorAvalista()->getDocumento())) == 14 ? 2 : 1);
            $this->add(155, 169, Util::formatCnab('9', Util::onlyNumbers($boleto->getSacadorAvalista()->getDocumento()), 15));
            $this->add(170, 199, Util::formatCnab('X', $boleto->getSacadorAvalista()->getNome(), 30));
        }

        return $this;
    }
534988
public function encrypt(CryptInterface $crypt)
    {
        foreach ($this->data  as $key => $value) {
            $this->set($key, $crypt->encrypt($value));
        }
    }
674991
public function accountRequest($segment, array $parameters=[]) {
        $baseUrl = $this->account_url;
        return $this->privateRequest($baseUrl, $segment, $parameters);
    }
531285
protected function setupSegment() {
		// Attempt to open shm segment
		$this->shm = @shmop_open($this->getIdentifier(), self::SHM_OPEN_MODE, 0, 0);

		// If segment doesn't exist init new segment
		if (false === $this->shm) {
			$this->createSegment();
		}
	}
287173
private function prepareSegment(string $name, string $segment): string
    {
        if (!empty($segment)) {
            return $this->filterSegment($segment);
        }

        if (!isset($this->constrains[$name])) {
            return self::DEFAULT_SEGMENT;
        }

        if (is_array($this->constrains[$name])) {
            $values = array_map([$this, 'filterSegment'], $this->constrains[$name]);

            return join('|', $values);
        }

        return $this->filterSegment((string)$this->constrains[$name]);
    }
253694
public Segment push(Segment segment) {
    segment.prev = this;
    segment.next = next;
    next.prev = segment;
    next = segment;
    return segment;
  }
1091825
public void setSegments(java.util.Collection<Segment> segments) {
        if (segments == null) {
            this.segments = null;
            return;
        }

        this.segments = new java.util.ArrayList<Segment>(segments);
    }
1200501
public function addEncryptedInvoices(\AgentSIB\Diadoc\Api\Proto\Events\EncryptedInvoiceAttachment $value)
    {
        if ($this->EncryptedInvoices === null) {
            $this->EncryptedInvoices = new \Protobuf\MessageCollection();
        }

        $this->EncryptedInvoices->add($value);
    }
1008623
public static function segment($segment, $default = null)
	{
		if ($request = \Request::active())
		{
			return $request->uri->get_segment($segment, $default);
		}

		return null;
	}
457157
public function prepend($segment)
    {
        $segments = is_array($segment) ? $segment : func_get_args();

        $newPath = $this->path->copy();

        foreach (array_reverse($segments) as $segment) {
            $newPath->prepend($segment);
        }

        return $this->replicate(['path' => $newPath]);
    }
245982
public function PostSegmentsRefresh(XsInt $segmentId)
    {
        $url = sprintf("segments/refresh/%s", $segmentId);
        return new ApiSegmentRefresh($this->execute($url, 'POST'));
    }