You are here

StreamCapturer.php in Drupal 10

Same filename and directory in other branches
  1. 9 core/tests/Drupal/Tests/StreamCapturer.php

Namespace

Drupal\Tests

File

core/tests/Drupal/Tests/StreamCapturer.php
View source
<?php

namespace Drupal\Tests;


/**
 * Captures output to a stream and stores it for retrieval.
 */
class StreamCapturer extends \php_user_filter {
  public static $cache = '';

  #[\ReturnTypeWillChange]
  public function filter($in, $out, &$consumed, $closing) {
    while ($bucket = stream_bucket_make_writeable($in)) {
      self::$cache .= $bucket->data;

      // cSpell:disable-next-line
      $consumed += $bucket->datalen;
      stream_bucket_append($out, $bucket);
    }

    // cSpell:disable-next-line
    return PSFS_FEED_ME;
  }

}

Classes

Namesort descending Description
StreamCapturer Captures output to a stream and stores it for retrieval.