StreamCapturer.php

Same filename in other branches
  1. 9 core/tests/Drupal/Tests/StreamCapturer.php
  2. 10 core/tests/Drupal/Tests/StreamCapturer.php

Namespace

Drupal\Tests

File

core/tests/Drupal/Tests/StreamCapturer.php

View source
<?php

declare (strict_types=1);
namespace Drupal\Tests;

// cspell:ignore datalen PSFS_FEED_ME writeable

/**
 * Captures output to a stream and stores it for retrieval.
 */
class StreamCapturer extends \php_user_filter {
    public static $cache = '';
    public function filter($in, $out, &$consumed, $closing) : int {
        while ($bucket = stream_bucket_make_writeable($in)) {
            self::$cache .= $bucket->data;
            $consumed += $bucket->datalen;
            stream_bucket_append($out, $bucket);
        }
        return PSFS_FEED_ME;
    }

}

Classes

Title Deprecated Summary
StreamCapturer Captures output to a stream and stores it for retrieval.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.