Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. AbstractStream.php

function AbstractStream::replace

2 calls to AbstractStream::replace()
SendmailTransport::doSend in vendor/symfony/mailer/Transport/SendmailTransport.php
SmtpTransport::doSend in vendor/symfony/mailer/Transport/Smtp/SmtpTransport.php

File

vendor/symfony/mailer/Transport/Smtp/Stream/AbstractStream.php, line 109

Class

AbstractStream
A stream supporting remote sockets and local processes.

Namespace

Symfony\Component\Mailer\Transport\Smtp\Stream

Code

public static function replace(string $from, string $to, iterable $chunks) : \Generator {
    if ('' === $from) {
        yield from $chunks;
        return;
    }
    $carry = '';
    $fromLen = \strlen($from);
    foreach ($chunks as $chunk) {
        if ('' === ($chunk = $carry . $chunk)) {
            continue;
        }
        if (str_contains($chunk, $from)) {
            $chunk = explode($from, $chunk);
            $carry = array_pop($chunk);
            (yield implode($to, $chunk) . $to);
        }
        else {
            $carry = $chunk;
        }
        if (\strlen($carry) > $fromLen) {
            (yield substr($carry, 0, -$fromLen));
            $carry = substr($carry, -$fromLen);
        }
    }
    if ('' !== $carry) {
        (yield $carry);
    }
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal