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 Info.class.php
Documentation is available at
Info.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 Report - Info
*
*
@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 Report - Info
*
@version
0.0.1
*/
gumbo_load
(
"Interface_Debug_Server_Report"
)
;
class
Gumbo_Debug_Server_Info
implements
Gumbo_Interface_Debug_Server_Report
{
/**
@var
int
$_mode
combined values of INFO_* constants for viewing PHP details */
private
$_mode
=
127
;
/**
* Constructor
*
@param
int
$mode
INFO_* Mode
*/
public
function
__construct
(
$mode
=
null
)
{
if
(
!
is_null
(
$mode
))
{
$this
->
setMode
(
$mode
)
;
}
}
/** ACTION METHODS **/
/**
* Runs the Report
*
@return
string
*/
public
function
run
(
)
{
return
phpinfo
(
$this
->
getMode
(
))
;
}
/**
* Adds to the current Information Mode
*
@param
int
$num
*
@throws
Gumbo_Exception
*/
public
function
addMode
(
$num
)
{
try
{
// verify precondition
if
(
!
is_numeric
(
$num
))
{
throw
new
Gumbo_Exception
(
"
Invalid
Argument
'
num
:
num
' => {
$num
}
:
"
.
gettype
(
$num
))
;
}
if
(
$num
< -
1
||
$num
>
127
)
{
throw
new
Gumbo_Exception
(
"
Out
Of
Range
'-1 <=
num
<= 127' => {
$num
}
"
)
;
}
if
(
$num
== -
1
)
{
$this
->
_mode
=
127
;
return
;
}
// check if proper number is given
switch
(
$num
)
{
case
INFO_GENERAL
:
break
;
case
INFO_CREDITS
:
break
;
case
INFO_CONFIGURATION
:
break
;
case
INFO_MODULES
:
break
;
case
INFO_ENVIRONMENT
:
break
;
case
INFO_VARIABLES
:
break
;
case
INFO_LICENSE
:
break
;
default
: throw
new
Gumbo_Exception
(
"
Invalid
INFO_
*
Constant
: {
$num
}
"
)
;
}
// check if mode is already set
if
(
$num
&
$this
->
getMode
(
))
{
return
;
}
$this
->
_mode
+=
$num
;
}
catch
(
Gumbo_Exception
$e
)
{
$e
->
setFunction
(
__METHOD__
)
;
gumbo_trigger
(
$e
)
;
}
}
/**
* Removes an Information Mode
*
@param
int
$num
*
@throws
Gumbo_Exception
*/
public
function
removeMode
(
$num
)
{
try
{
// verify precondition
if
(
!
is_int
(
$num
))
{
throw
new
Gumbo_Exception
(
"
Invalid
Argument
'
num
:
int
' => {
$num
}
:
"
.
gettype
(
$num
))
;
}
if
(
$num
< -
1
||
$num
>
127
)
{
throw
new
Gumbo_Exception
(
"
Out
Of
Range
'-1 <=
num
<= 127' => {
$num
}
"
)
;
}
if
(
$num
== -
1
)
{
$this
->
_mode
=
127
;
return
;
}
// check if proper number is given
switch
(
$num
)
{
case
INFO_GENERAL
:
break
;
case
INFO_CREDITS
:
break
;
case
INFO_CONFIGURATION
:
break
;
case
INFO_MODULES
:
break
;
case
INFO_ENVIRONMENT
:
break
;
case
INFO_VARIABLES
:
break
;
case
INFO_LICENSE
:
break
;
default
: throw
new
Gumbo_Exception
(
"
Invalid
INFO_
*
Constant
: {
$num
}
"
)
;
}
// check if mode is already set
if
(
!
(
$num
&
$this
->
getMode
(
)))
{
return
;
}
$this
->
_mode
-=
$num
;
}
catch
(
Gumbo_Exception
$e
)
{
$e
->
setFunction
(
__METHOD__
)
;
gumbo_trigger
(
$e
)
;
}
}
/** MUTATOR METHODS **/
/**
* Sets the INFO_* mode
*
@param
int
$mode
*
@throws
Gumbo_Exception
*/
public
function
setMode
(
$mode
)
{
try
{
// verify precondition
if
(
!
is_int
(
$mode
))
{
throw
new
Gumbo_Exception
(
"
Invalid
Argument
'
mode
:
int
' => {
$mode
}
:
"
.
gettype
(
$mode
))
;
}
if
(
$mode
< -
1
||
$mode
>
127
)
{
throw
new
Gumbo_Exception
(
"
Out
Of
Range
'-1 <=
mode
<= 127' => {
$mode
}
"
)
;
}
$this
->
_mode
=
$mode
;
}
catch
(
Gumbo_Exception
$e
)
{
$e
->
setFunction
(
__METHOD__
)
;
gumbo_trigger
(
$e
)
;
}
}
/** ACCESSOR METHODS **/
/**
* Returns the INFO_* Mode value
*
@return
int
*/
public
function
getMode
(
)
{
if
(
$this
->
_mode
==
127
)
{
return
-
1
;
}
return
$this
->
_mode
;
}
}
?>