Hoa central
LateComputed.php
Go to the documentation of this file.
1 <?php
2 
37 namespace Hoa\Stream\Filter;
38 
39 use Hoa\Stream;
40 
49 abstract class LateComputed extends Basic
50 {
56  protected $_buffer = null;
57 
58 
59 
81  public function filter($in, $out, &$consumed, $closing)
82  {
83  $return = self::FEED_ME;
84  $iBucket = new Stream\Bucket($in);
85 
86  while (false === $iBucket->eob()) {
87  $this->_buffer .= $iBucket->getData();
88  $consumed += $iBucket->getLength();
89  }
90 
91  if (null !== $consumed) {
92  $return = self::PASS_ON;
93  }
94 
95  if (true === $closing) {
96  $stream = $this->getStream();
97  $this->compute();
98  $bucket = new Stream\Bucket(
99  $stream,
101  $this->_buffer
102  );
103  $oBucket = new Stream\Bucket($out);
104  $oBucket->append($bucket);
105 
106  $return = self::PASS_ON;
107  $this->_buffer = null;
108  }
109 
110  return $return;
111  }
112 
118  abstract protected function compute();
119 }
const IS_A_STREAM
Definition: Bucket.php:61
filter($in, $out, &$consumed, $closing)