Gumbo PHP Library API Documentation
Buffer
[
class tree
] [
index
] [
all elements
]
Todo List
Packages:
Buffer
Collection
Composite
Config
Converter
Curl
Date
DB
Debug
Encryption
Error
Factory
Filter
Flyweight
Http
Input
Iterator
List
Load
Lockable
Log
Map
Number
Observer
Output
Query
Record
Router
Session
Setting
Singleton
Template
Timer
Utility
Valid
Source for file Buffer.class.php
Documentation is available at
Buffer.class.php
<?php
/**
* Gumbo Library Framework
*
* LICENSE
* This library is being released under the terms of the New BSD License. A
* copy of the license is packaged with the software (LICENSE.txt). If no
* copy is found, a copy of the license template can be found at:
* http://www.opensource.org/licenses/bsd-license.php
*
*
@category
Gumbo
*
@package
Buffer
*
@copyright
Copyright (c) 2007, iBayou, Michael Luster
*
@license
http://www.opensource.org/licenses/bsd-license.php New BSD License
*
@author
Michael Luster <mluster79@yahoo.com>
*
@link
http://sourceforge.net/projects/phpgumbo
*
@version
0.0.1
*/
/**
* Buffer Class
*
* This class is simply meant to provide an OOP interface for
* creating a PHP buffer. It starts on construction, and ends
* when the object is destroyed. The methods will perform
* basic operations on the buffer.
*
* This class does not perform advanced functionality on output
* buffers.
*
* To use the buffer, simply create a new instance of the object
* when the buffer should start. Send any content to the browser,
* the buffer will catch. Once the buffer is finished, simply
* destroy the object:
* <pre>
* $buffer = new Gumbo_Buffer ();
* // insert output code
* // ...
* $buffer = null; or unset ($buffer);
* </pre>
*
*
@category
Gumbo
*
@package
Buffer
*
@copyright
Copyright (c) 2007, iBayou, Michael Luster
*
@license
http://www.opensource.org/licenses/bsd-license.php New BSD License
*
@author
Michael Luster <mluster79@yahoo.com>
*
@link
http://sourceforge.net/projects/phpgumbo
*
@desc
Buffer Class
*
@version
0.0.1
*/
gumbo_load
(
"Interface_Buffer"
)
;
class
Gumbo_Buffer
implements
Gumbo_Interface_Buffer
{
/**
* Constructor - starts the buffer
*
@postcondition
ob_start ()
*/
public
function
__construct
(
)
{
ob_start
(
)
;
}
/**
* Destructor - ends the buffer
* $buffer = null; or unset ($buffer);
*
@postcondition
ob_end_clean ()
*/
public
function
__destruct
(
)
{
ob_end_clean
(
)
;
}
/** ACTION METHODS **/
/**
* Cleans the output buffer: ob_clean ()
*/
public
function
clean
(
)
{
ob_clean
(
)
;
}
/**
* Flushes the contents of the buffer to the browser: ob_flush ()
*/
public
function
flush
(
)
{
ob_flush
(
)
;
}
/** ACCESSOR METHODS **/
/**
* Returns the contents of the buffer: ob_get_contents ()
*
@param
bool
$clean
cleans the buffer after getting the contents
*
@return
string
*/
public
function
contents
(
$clean
=
false
)
{
try
{
// verify precondition
if
(
!
is_bool
(
$clean
))
{
throw
new
Gumbo_Exception
(
"
Invalid
Argument
'
clean
:
bool
' => {
$clean
}
:
"
.
gettype
(
$clean
))
;
}
}
catch
(
Gumbo_Exception
$e
)
{
$e
->
setFunction
(
__METHOD__
)
;
gumbo_trigger
(
$e
)
;
$clean
=
false
;
}
$txt
=
ob_get_contents
(
)
;
if
(
$clean
)
{
$this
->
clean
(
)
;
}
return
$txt
;
}
/**
* Returns the size of the buffer: ob_get_length ()
*
@return
int
*/
public
function
size
(
)
{
return
ob_get_length
(
)
;
}
}
?>