Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
n/a
0 / 0
n/a
0 / 0
CRAP
n/a
0 / 0
Stream
n/a
0 / 0
n/a
0 / 0
4
n/a
0 / 0
 filter
n/a
0 / 0
n/a
0 / 0
2
 init
n/a
0 / 0
n/a
0 / 0
0
 getContents
n/a
0 / 0
n/a
0 / 0
1
 reset
n/a
0 / 0
n/a
0 / 0
1
1<?php declare(strict_types=1);
2/*
3 * This file is part of Aplus Framework CLI Library.
4 *
5 * (c) Natan Felles <natanfelles@gmail.com>
6 *
7 * For the full copyright and license information, please view the LICENSE
8 * file that was distributed with this source code.
9 */
10namespace Framework\CLI\Streams;
11
12use JetBrains\PhpStorm\Pure;
13
14/**
15 * Class Stream.
16 *
17 * @package cli
18 *
19 * @deprecated
20 *
21 * @codeCoverageIgnore
22 */
23abstract class Stream extends \php_user_filter
24{
25    protected static string $contents = '';
26
27    /**
28     * @param resource $in
29     * @param resource $out
30     * @param int $consumed
31     * @param bool $closing
32     *
33     * @see https://php.net/manual/en/php-user-filter.filter.php
34     *
35     * @return int
36     */
37    public function filter($in, $out, &$consumed, $closing) : int
38    {
39        while ($bucket = \stream_bucket_make_writeable($in)) {
40            static::$contents .= $bucket->data;
41            $consumed += $bucket->datalen;
42            \stream_bucket_append($out, $bucket);
43        }
44        return \PSFS_FEED_ME;
45    }
46
47    abstract public static function init() : void;
48
49    #[Pure]
50    public static function getContents() : string
51    {
52        return static::$contents;
53    }
54
55    public static function reset() : void
56    {
57        static::$contents = '';
58    }
59}