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

Breadcrumb

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

function Base64ContentEncoder::encodeByteStream

Overrides ContentEncoderInterface::encodeByteStream

File

vendor/symfony/mime/Encoder/Base64ContentEncoder.php, line 21

Class

Base64ContentEncoder
@author Fabien Potencier <fabien@symfony.com>

Namespace

Symfony\Component\Mime\Encoder

Code

public function encodeByteStream($stream, int $maxLineLength = 0) : iterable {
    if (!\is_resource($stream)) {
        throw new \TypeError(\sprintf('Method "%s" takes a stream as a first argument.', __METHOD__));
    }
    $filter = stream_filter_append($stream, 'convert.base64-encode', \STREAM_FILTER_READ, [
        'line-length' => 0 >= $maxLineLength || 76 < $maxLineLength ? 76 : $maxLineLength,
        'line-break-chars' => "\r\n",
    ]);
    if (!\is_resource($filter)) {
        throw new RuntimeException('Unable to set the base64 content encoder to the filter.');
    }
    while (!feof($stream)) {
        (yield fread($stream, 16372));
    }
    stream_filter_remove($filter);
}

API Navigation

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