Hoa central
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
Hoa\Stream\Bucket Class Reference

Public Member Functions

 __construct (&$brigade, $is=self::IS_A_BRIGADE, $buffer= '')
 
 eob ()
 
 append (Bucket $bucket)
 
 prepend (Bucket $bucket)
 
 getType ()
 
 setData ($data)
 
 getData ()
 
 getLength ()
 
 getBrigade ()
 

Public Attributes

const IS_A_BRIGADE = true
 
const IS_A_STREAM = false
 

Protected Member Functions

 setType ($type)
 
 setBrigade (&$brigade)
 
 setBucket ($bucket)
 
 getBucket ()
 

Protected Attributes

 $_type = null
 
 $_brigade = null
 
 $_bucket = null
 

Detailed Description

Class .

Manipulate stream buckets through brigades.

Definition at line 47 of file Bucket.php.

Constructor & Destructor Documentation

Hoa\Stream\Bucket::__construct ( $brigade,
  $is = self::IS_A_BRIGADE,
  $buffer = '' 
)

Set a brigade. If a stream is given (with the constant self::IS_A_STREAM), it will create a brigade automatically.

Parameters
resource&$brigadeA stream or a brigade.
bool$isSpecify if $brigade is a stream or a brigade, given by self::IS_A_* constant.
string$bufferStream buffer.
Returns
void

Definition at line 97 of file Bucket.php.

98  {
99  $this->setType($is);
100 
101  if (self::IS_A_BRIGADE === $this->getType()) {
102  $this->setBrigade($brigade);
103  } else {
104  $this->setBucket(stream_bucket_new($brigade, $buffer));
105  $bucket = $this->getBucket();
106  $this->setBrigade($bucket);
107  }
108 
109  return;
110  }
setBucket($bucket)
Definition: Bucket.php:248
setType($type)
Definition: Bucket.php:157
setBrigade(&$brigade)
Definition: Bucket.php:224

Here is the call graph for this function:

Member Function Documentation

Hoa\Stream\Bucket::append ( Bucket  $bucket)

Append bucket to the brigade.

Parameters
\Hoa\Stream\Bucket$bucketBucket to add.
Returns
void

Definition at line 131 of file Bucket.php.

132  {
133  stream_bucket_append($this->getBrigade(), $bucket->getBucket());
134 
135  return;
136  }

Here is the call graph for this function:

Hoa\Stream\Bucket::eob ( )

Test the end-of-bucket. When testing, set the new bucket object.

Returns
bool

Definition at line 118 of file Bucket.php.

119  {
120  $this->_bucket = null;
121 
122  return false == $this->getBucket();
123  }

Here is the call graph for this function:

Hoa\Stream\Bucket::getBrigade ( )

Get the brigade.

Returns
resource

Definition at line 237 of file Bucket.php.

238  {
239  return $this->_brigade;
240  }

Here is the caller graph for this function:

Hoa\Stream\Bucket::getBucket ( )
protected

Get the current bucket.

Returns
mixed

Definition at line 261 of file Bucket.php.

262  {
263  if (null === $this->_bucket && self::IS_A_BRIGADE === $this->getType()) {
264  $this->_bucket = stream_bucket_make_writeable($this->getBrigade());
265  }
266 
267  return $this->_bucket;
268  }

Here is the call graph for this function:

Here is the caller graph for this function:

Hoa\Stream\Bucket::getData ( )

Get bucket data.

Returns
string

Definition at line 195 of file Bucket.php.

196  {
197  if (null === $this->getBucket()) {
198  return null;
199  }
200 
201  return $this->getBucket()->data;
202  }

Here is the call graph for this function:

Hoa\Stream\Bucket::getLength ( )

Get bucket length.

Returns
int

Definition at line 209 of file Bucket.php.

210  {
211  if (null === $this->getBucket()) {
212  return 0;
213  }
214 
215  return $this->getBucket()->datalen;
216  }

Here is the call graph for this function:

Hoa\Stream\Bucket::getType ( )

Get type.

Returns
bool

Definition at line 170 of file Bucket.php.

171  {
172  return $this->_type;
173  }

Here is the caller graph for this function:

Hoa\Stream\Bucket::prepend ( Bucket  $bucket)

Prepend bucket to the brigade.

Parameters
\Hoa\Stream\Bucket$bucketBucket to add.
Returns
void

Definition at line 144 of file Bucket.php.

145  {
146  stream_bucket_prepend($this->getBrigade(), $bucket->getBucket());
147 
148  return;
149  }

Here is the call graph for this function:

Hoa\Stream\Bucket::setBrigade ( $brigade)
protected

Set the brigade.

Parameters
resource&$brigadeBrigade to add.
Returns
resource

Definition at line 224 of file Bucket.php.

225  {
226  $old = $this->_brigade;
227  $this->_brigade = $brigade;
228 
229  return $old;
230  }

Here is the caller graph for this function:

Hoa\Stream\Bucket::setBucket (   $bucket)
protected

Set bucket.

Parameters
resource$bucketBucket.
Returns
resource

Definition at line 248 of file Bucket.php.

249  {
250  $old = $this->_bucket;
251  $this->_bucket = $bucket;
252 
253  return $old;
254  }

Here is the caller graph for this function:

Hoa\Stream\Bucket::setData (   $data)

Set bucket data.

Parameters
string$dataData to set. string

Definition at line 181 of file Bucket.php.

182  {
183  $old = $this->getBucket()->data;
184  $this->getBucket()->data = $data;
185  $this->getBucket()->datalen = strlen($this->getBucket()->data);
186 
187  return $old;
188  }

Here is the call graph for this function:

Hoa\Stream\Bucket::setType (   $type)
protected

Set type.

Parameters
bool$typeType. Please, see self::IS_A_* constants.
Returns
bool

Definition at line 157 of file Bucket.php.

158  {
159  $old = $this->_type;
160  $this->_type = $type;
161 
162  return $old;
163  }

Here is the caller graph for this function:

Member Data Documentation

Hoa\Stream\Bucket::$_brigade = null
protected

Definition at line 75 of file Bucket.php.

Hoa\Stream\Bucket::$_bucket = null
protected

Definition at line 82 of file Bucket.php.

Hoa\Stream\Bucket::$_type = null
protected

Definition at line 68 of file Bucket.php.

const Hoa\Stream\Bucket::IS_A_BRIGADE = true

Whether the stream is already a brigade.

bool

Definition at line 54 of file Bucket.php.

const Hoa\Stream\Bucket::IS_A_STREAM = false

Whether the stream is not a brigade.

bool

Definition at line 61 of file Bucket.php.


The documentation for this class was generated from the following file: