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 File.class.php
Documentation is available at
File.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 - File
*
*
@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 - File
*
@version
0.0.1
*/
gumbo_load
(
"Interface_Debug_Server_Report"
)
;
class
Gumbo_Debug_Server_File
implements
Gumbo_Interface_Debug_Server_Report
{
/**
@var
array
$_paths
list of Paths to remove from return string */
private
$_paths
=
array
(
)
;
/**
* Constructor
*
@param
arr
$args
*/
public
function
__construct
(
$args
=
null
)
{
$args
=
func_get_args
(
)
;
call_user_func_array
(
array
(
$this
,
"setPaths"
)
,
$args
)
;
}
/** ACTION METHODS **/
/**
* Runs the Report
*
@return
string
*/
public
function
run
(
)
{
$txt
.=
"<div class=\"debug\">\n"
;
$txt
.=
"\t<ul>Included Files\n"
;
foreach
(
get_included_files
(
)
as
$val
)
{
$txt
.=
"
\t\t<
li
>{
$this
->
parse
(
$val
)
}
</
li
>\n
"
;
}
$txt
.=
"\t</ul>\n"
;
$txt
.=
"</div>\n\n"
;
return
$txt
;
}
/**
* Parses active Paths from the string
*
@param
string
$txt
*
@return
string
*
@throws
Gumbo_Exception
*/
protected
function
parse
(
$txt
)
{
try
{
// verify precondition
if
(
!
is_string
(
$txt
))
{
throw
new
Gumbo_Exception
(
"
Invalid
Argument
'
txt
:
str
' => {
$txt
}
:
"
.
gettype
(
$txt
))
;
}
foreach
(
$this
->
getPaths
(
)
as
$path
)
{
$txt
=
str_replace
(
$path
,
""
,
$txt
)
;
}
}
catch
(
Gumbo_Exception
$e
)
{
$e
->
setFunction
(
__METHOD__
)
;
gumbo_trigger
(
$e
)
;
}
return
$txt
;
}
/**
* Adds a Path
*
@precondition
!isPath()
*
@param
string
$path
*
@throws
Gumbo_Exception
*/
public
function
addPath
(
$path
)
{
try
{
// verify precondition
if
(
!
is_string
(
$path
))
{
throw
new
Gumbo_Exception
(
"
Invalid
Argument
'
path
:
str
' => {
$path
}
:
"
.
gettype
(
$path
))
;
}
if
(
!
is_dir
(
$path
))
{
throw
new
Gumbo_Exception
(
"
Invalid
Directory
: {
$path
}
"
)
;
}
if
(
$this
->
isPath
(
$path
))
{
throw
new
Gumbo_Exception
(
"
Path
Defined
: {
$path
}
"
)
;
}
$this
->
_paths
[
]
=
$path
;
}
catch
(
Gumbo_Exception
$e
)
{
$e
->
setFunction
(
__METHOD__
)
;
gumbo_trigger
(
$e
)
;
}
}
/**
* Removes a Path
*
@precondition
isPath()
*
@param
string
$path
*
@throws
Gumbo_Exception
*/
public
function
removePath
(
$path
)
{
try
{
// verify precondition
if
(
!
is_string
(
$path
))
{
throw
new
Gumbo_Exception
(
"
Invalid
Argument
'
path
:
str
' => {
$path
}
:
"
.
gettype
(
$path
))
;
}
if
(
!
$this
->
isPath
(
$path
))
{
throw
new
Gumbo_Exception
(
"
Path
Undefined
: {
$path
}
"
)
;
}
foreach
(
$this
->
getPaths
(
)
as
$key
=>
$val
)
{
if
(
$val
==
$path
)
{
unset
(
$this
->
_paths
[
$key
]
)
;
break
;
}
}
}
catch
(
Gumbo_Exception
$e
)
{
$e
->
setFunction
(
__METHOD__
)
;
gumbo_trigger
(
$e
)
;
}
}
/**
* Resets the Paths
*
@postcondition
!getPaths()
*/
public
function
resetPaths
(
)
{
$this
->
_paths
=
array
(
)
;
}
/** MUTATOR METHODS **/
/**
* Sets the Paths that should be removed from the output
*
@param
arr
$args
*/
public
function
setPaths
(
$args
=
null
)
{
if
(
is_null
(
$args
)
||
func_num_args
(
)
==
0
)
{
return
;
}
// check for multiple arguments
if
(
func_num_args
(
)
>
1
)
{
$args
=
func_get_args
(
)
;
}
// check for an array
if
(
is_array
(
$args
))
{
foreach
(
$args
as
$val
)
{
$this
->
setPaths
(
$val
)
;
}
return
;
}
// add the Path
$this
->
addPath
(
$args
)
;
}
/** ACCESSOR METHODS **/
public
function
getPaths
(
)
{
return
$this
->
_paths
;
}
/**
* Returns if a Path exists
*
@param
string
$path
*
@return
bool
*
@throws
Gumbo_Exception
*/
public
function
isPath
(
$path
)
{
$found
=
false
;
try
{
// verify precondition
// verify precondition
if
(
!
is_string
(
$path
))
{
throw
new
Gumbo_Exception
(
"
Invalid
Argument
'
path
:
str
' => {
$path
}
:
"
.
gettype
(
$path
))
;
}
foreach
(
$this
->
getPaths
(
)
as
$val
)
{
if
(
$val
==
$path
)
{
$found
=
true
;
break
;
}
}
}
catch
(
Gumbo_Exception
$e
)
{
$e
->
setFunction
(
__METHOD__
)
;
gumbo_trigger
(
$e
)
;
}
return
$found
;
}
}
?>