Gumbo PHP Library API Documentation
Debug
[
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 Server.class.php
Documentation is available at
Server.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
Debug
*
@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
*/
/**
* Debug Server Class
*
*
@category
Gumbo
*
@package
Debug
*
@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
Debug Server Class
*
@version
0.0.1
*/
gumbo_load
(
"Interface_Singleton"
)
;
gumbo_load
(
"Interface_Output"
)
;
gumbo_load
(
"Factory"
)
;
gumbo_load
(
"Debug_Server_Blank"
)
;
class
Gumbo_Debug_Server
extends
Gumbo_Factory
implements
Gumbo_Interface_Singleton
,
Gumbo_Interface_Output
{
/**
@var
Gumbo_Interface_Debug_Server
$_instance
*/
private
static
$_instance
=
null
;
/**
@var
Gumbo_Interface_Debug_Server_Report
$_reports
*/
private
$_reports
=
false
;
/**
* Constructor
*/
private
function
__construct
(
)
{
}
/**
* Singleton Method
*
@return
Gumbo_Interface_Debug_Server
*/
public
static
function
instance
(
)
{
if
(
self
::
$_instance
==
null
)
{
self
::
$_instance
=
new
Gumbo_Debug_Server
(
)
;
}
return
self
::
$_instance
;
}
/** ACTION METHODS **/
/**
* Returns a Debug Server Report
*
@param
string
$name
name of Class or key string
*
@param
mixed
$args
additional arguments
*
@return
Gumbo_Interface_Debug_Server_Report
*
@throws
Gumbo_Exception
*
@uses
Gumbo_Debug_Server_Blank
*/
public
function
factory
(
$name
=
null
,
$args
=
null
)
{
try
{
// prepend Gumbo_Filter_ if class does not exist
if
(
is_string
(
$name
)
&&
!
class_exists
(
$name
,
false
))
{
$name
=
"Gumbo_Debug_Server_"
.
ucfirst
(
str_replace
(
"Gumbo_Debug_Server_"
,
""
,
$name
))
;
}
$args
=
array
(
)
;
$args
[
]
=
$name
;
foreach
(
func_get_args
(
)
as
$key
=>
$val
)
{
if
(
$key
==
0
)
{
continue
;
}
$args
[
]
=
$val
;
}
$obj
=
call_user_func_array
(
array
(
"parent"
,
"factory"
)
,
$args
)
;
if
(
!
(
$obj
instanceof
Gumbo_Interface_Debug_Server_Report
))
{
throw
new
Gumbo_Exception
(
"Invalid Debug Server Report: "
.
get_class
(
$obj
))
;
}
return
$obj
;
}
catch
(
Gumbo_Exception
$e
)
{
$e
->
setFunction
(
__METHOD__
)
;
gumbo_trigger
(
$e
)
;
}
return
new
Gumbo_Debug_Server_Blank
(
)
;
}
/**
* Activates a Server Report
*
@param
string
$report
Debug Server Report Name
*
@param
arr
$args
additional arguments
*
@throws
Gumbo_Exception
*
@uses
Gumbo_Debug_Server_Blank
*/
public
function
activate
(
$report
,
$args
=
null
)
{
try
{
// verify precondition
if
(
!
is_string
(
$report
))
{
throw
new
Gumbo_Exception
(
"
Invalid
Argument
'
report
:
str
' => {
$report
}
:
"
.
gettype
(
$report
))
;
}
if
(
!
$this
->
exists
(
$report
))
{
throw
new
Gumbo_Exception
(
"
Debug
Server
Report
Not
Found
: {
$report
}
"
)
;
}
if
(
$this
->
isActive
(
$report
))
{
throw
new
Gumbo_Exception
(
"
Debug
Server
Report
Active
: {
$report
}
"
)
;
}
$args
=
func_get_args
(
)
;
$obj
=
call_user_func_array
(
array
(
$this
,
"factory"
)
,
$args
)
;
if
(
!
(
$obj
instanceof
Gumbo_Debug_Server_Blank
))
{
$this
->
_reports
[
$report
]
=
$obj
;
}
}
catch
(
Gumbo_Exception
$e
)
{
$e
->
setFunction
(
__METHOD__
)
;
gumbo_trigger
(
$e
)
;
}
}
/**
* Deactivates a Server Report
*
@param
string
$report
Debug Server Report Name
*
@throws
Gumbo_Exception
*/
public
function
deactivate
(
$report
)
{
try
{
// verify precondition
if
(
!
is_string
(
$report
))
{
throw
new
Gumbo_Exception
(
"
Invalid
Argument
'
report
:
str
' => {
$report
}
:
"
.
gettype
(
$report
))
;
}
if
(
!
$this
->
isActive
(
$report
))
{
throw
new
Gumbo_Exception
(
"
Debug
Server
Report
Not
Active
: {
$report
}
"
)
;
}
unset
(
$this
->
_reports
[
$report
]
)
;
}
catch
(
Gumbo_Exception
$e
)
{
$e
->
setFunction
(
__METHOD__
)
;
gumbo_trigger
(
$e
)
;
}
}
/**
* Resets the Reports
*
@postcondition
!isActive()
*/
public
function
reset
(
)
{
$this
->
_reports
=
array
(
)
;
}
/**
* Displays to the browser
*/
public
function
display
(
)
{
echo
$this
->
fetch
(
)
;
}
/**
* Returns the formatted text to the browser
*
@param
bool
$reload
reloads the output
*
@return
string
*/
public
function
fetch
(
$reload
=
false
)
{
$txt
=
false
;
foreach
(
$this
->
getReports
(
)
as
$key
=>
$report
)
{
$txt
.=
$report
->
run
(
)
;
}
return
$txt
;
}
/** ACCESSOR METHODS **/
/**
* Returns a single Report
*
@param
string
$report
*
@return
Gumbo_Interface_Debug_Server_Report
*
@throws
Gumbo_Exception
*/
public
function
getReport
(
$report
)
{
try
{
// verify precondition
if
(
!
is_string
(
$report
))
{
throw
new
Gumbo_Exception
(
"
Invalid
Argument
'
report
:
str
' => {
$report
}
:
"
.
gettype
(
$report
))
;
}
if
(
!
$this
->
isActive
(
$report
))
{
throw
new
Gumbo_Exception
(
"
Debug
Server
Report
Not
Active
: {
$report
}
"
)
;
}
return
$this
->
_reports
[
$report
]
;
}
catch
(
Gumbo_Exception
$e
)
{
$e
->
setFunction
(
__METHOD__
)
;
gumbo_trigger
(
$e
)
;
}
return
null
;
}
/**
* Returns the Debug Server Reports
*
@return
Gumbo_Interface_Debug_Server_Report[]
*/
public
function
getReports
(
)
{
return
$this
->
_reports
;
}
/**
* Returns if a particular Report is active
*
@param
string
$report
*
@return
bool
*
@throws
Gumbo_Exception
*/
public
function
isActive
(
$report
)
{
try
{
// verify precondition
if
(
!
is_string
(
$report
))
{
throw
new
Gumbo_Exception
(
"
Invalid
Argument
'
report
:
str
' => {
$report
}
:
"
.
gettype
(
$report
))
;
}
return
isset
(
$this
->
_reports
[
$report
]
)
;
}
catch
(
Gumbo_Exception
$e
)
{
$e
->
setFunction
(
__METHOD__
)
;
gumbo_trigger
(
$e
)
;
}
return
false
;
}
/**
* Returns if the Report exists
*
@param
string
$report
*
@return
bool
*
@throws
Gumbo_Exception
*/
public
function
exists
(
$report
)
{
try
{
// verify precondition
if
(
!
is_string
(
$report
))
{
throw
new
Gumbo_Exception
(
"
Invalid
Argument
'
report
:
str
' => {
$report
}
:
"
.
gettype
(
$report
))
;
}
$report
=
"Gumbo_Debug_Server_Report_"
.
str_replace
(
"Gumbo_Debug_Server_Report_"
,
""
,
$report
)
;
return
gumbo_load
(
$report
)
;
}
catch
(
Gumbo_Exception
$e
)
{
$e
->
setFunction
(
__METHOD__
)
;
gumbo_trigger
(
$e
)
;
}
return
false
;
}
/**
* Returns the object as a string
*
@return
string
*/
public
function
__toString
(
)
{
return
$this
->
fetch
(
)
;
}
}
?>