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 Message.class.php
Documentation is available at
Message.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 Message 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 Message Class
*
@version
0.0.1
*/
gumbo_load
(
"Interface_Debug_Message"
)
;
class
Gumbo_Debug_Message
implements
Gumbo_Interface_Debug_Message
{
/**
@var
num
$_time
timestamp when message was created */
private
$_time
;
/**
@var
num
$_seconds
time to execute Debug Message */
private
$_seconds
=
0
;
/**
@var
int
$_line
line where message occured */
private
$_line
;
/**
@var
string
$_file
file where message was created */
private
$_file
;
/**
@var
string
$_class
class name */
private
$_class
;
/**
@var
string
$_function
method/function of message */
private
$_function
;
/**
@var
string
$_message
the custom message */
private
$_message
;
/**
* Constructor
*
@param
string
$mess
message
*
@param
string
$file
file name __FILE__
*
@param
int
$line
line number __LINE__
*
@param
string
$func
function/method name __FUNCTION__
*
@param
string
$cls
class name __CLASS__
*/
public
function
__construct
(
$mess
,
$file
,
$line
,
$func
=
null
,
$cls
=
null
)
{
$this
->
_setTime
(
microtime
(
true
))
;
$this
->
setMessage
(
$mess
)
;
$this
->
setFile
(
$file
)
;
$this
->
setLine
(
$line
)
;
if
(
!
is_null
(
$cls
))
{
$this
->
setClass
(
$cls
)
;
}
if
(
!
is_nul
(
$func
))
{
$this
->
setFunction
(
$func
)
;
}
}
/** ACTION METHODS **/
/** MUTATOR METHODS **/
/**
* Sets the time stamp when the message was created
*
@param
num
$time
*
@throws
Gumbo_Exception
*/
private
function
_setTime
(
$time
)
{
try
{
// verify precondition
if
(
!
is_numeric
(
$time
))
{
throw
new
Gumbo_Exception
(
"
Invalid
Argument
'
time
:
num
' => {
$time
}
:
"
.
gettype
(
$time
))
;
}
$this
->
_time
=
$time
;
}
catch
(
Gumbo_Exception
$e
)
{
$e
->
setFunction
(
__METHOD__
)
;
gumbo_trigger
(
$e
)
;
}
}
/**
* Sets the message contents of the message
*
@param
string
$mess
*
@throws
Gumbo_Exception
*/
public
function
setMessage
(
$mess
)
{
try
{
// verify precondtion
if
(
!
is_string
(
$mess
))
{
throw
new
Gumbo_Exception
(
"
Invalid
Argument
'
mess
:
str
' => {
$mess
}
:
"
.
gettype
(
$mess
))
;
}
$this
->
_message
=
$mess
;
}
catch
(
Gumbo_Exception
$e
)
{
$e
->
setFunction
(
__METHOD__
)
;
gumbo_trigger
(
$e
)
;
}
}
/**
* Sets the file where the message occured
*
@precondition
file_exists ($file)
*
@param
string
$file
*
@throws
Gumbo_Exception
*/
public
function
setFile
(
$file
)
{
try
{
// verify precondition
if
(
!
is_string
(
$file
))
{
throw
new
Gumbo_Exception
(
"
Invalid
Argument
'
file
:
str
' => {
$file
}
:
"
.
gettype
(
$file
))
;
}
if
(
!
file_exists
(
$file
))
{
throw
new
Gumbo_Exception
(
"
File
Not
Found
: {
$file
}
"
)
;
}
$this
->
_file
=
$file
;
}
catch
(
Gumbo_Exception
$e
)
{
$e
->
setFunction
(
__METHOD__
)
;
gumbo_trigger
(
$e
)
;
}
}
/**
* Sets the line number of the message
*
@param
int
$line
*
@throws
Gumbo_Exception
*/
public
function
setLine
(
$line
)
{
try
{
// verify precondition
if
(
!
is_int
(
$line
))
{
throw
new
Gumbo_Exception
(
"
Invalid
Argument
'
line
:
int
' => {
$line
}
:
"
.
gettype
(
$line
))
;
}
if
(
$line
<
0
)
{
throw
new
Gumbo_Exception
(
"
Must
Be
Positive
Number
: {
$line
}
"
)
;
}
$this
->
_line
=
$line
;
}
catch
(
Gumbo_Exception
$e
)
{
$e
->
setFunction
(
__METHOD__
)
;
gumbo_trigger
(
$e
)
;
}
}
/**
* Sets the function/method name
*
@precondition
function_exists ($func)
*
@param
string
$func
*
@throws
Gumbo_Exception
*/
public
function
setFunction
(
$func
)
{
try
{
// verify precondition
if
(
!
is_string
(
$func
))
{
throw
new
Gumbo_Exception
(
"
Invalid
Argument
'
func
:
str
' => {
$func
}
:
"
.
gettype
(
$func
))
;
}
if
(
$this
->
getClass
(
)
&&
!
method_exists
(
$this
->
getClass
(
)
,
$func
))
{
throw
new
Gumbo_Exception
(
"Class Method Does Not Exist: "
.
$this
->
getClass
(
)
.
"
::{
$func
}
"
)
;
}
if
(
!
$this
->
getClass
(
)
&&
!
function_exists
(
$func
))
{
throw
new
Gumbo_Exception
(
"
Function
Does
Not
Exist
: {
$func
}
"
)
;
}
$this
->
_function
=
$func
;
}
catch
(
Gumbo_Exception
$e
)
{
$e
->
setFunction
(
__METHOD__
)
;
gumbo_trigger
(
$e
)
;
}
}
/**
* Sets the class name
*
@precondtion
class_exists ($cls)
*
@param
string
$cls
*
@throws
Gumbo_Exception
*/
public
function
setClass
(
$cls
)
{
try
{
// verify precondition
if
(
!
is_string
(
$cls
))
{
throw
new
Gumbo_Exception
(
"
Invalid
Argument
'
cls
:
str
' => {
$cls
}
:
"
.
gettype
(
$cls
))
;
}
if
(
!
class_exists
(
$cls
,
false
))
{
throw
new
Gumbo_Exception
(
"
Class
|
Interface
Does
Not
Exist
: {
$cls
}
"
)
;
}
$this
->
_class
=
$cls
;
if
(
$this
->
getFunction
(
))
{
$this
->
setFunction
(
$this
->
getFunction
(
))
;
}
}
catch
(
Gumbo_Exception
$e
)
{
$e
->
setFunction
(
__METHOD__
)
;
gumbo_trigger
(
$e
)
;
}
}
/**
* Sets the time (in seconds) to get to debug message from last message
*
@param
num
$time
*/
public
function
setSeconds
(
$time
=
null
)
{
try
{
// verify precondition
if
(
!
is_null
(
$time
)
&&
!
is_numeric
(
$time
))
{
throw
new
Gumbo_Exception
(
"
Invalid
Argument
'
time
:
num
' => {
$time
}
:
"
.
gettype
(
$time
))
;
}
}
catch
(
Gumbo_Exception
$e
)
{
$e
->
setFunction
(
__METHOD__
)
;
gumbo_trigger
(
$e
)
;
$time
=
null
;
}
if
(
is_null
(
$time
))
{
$time
=
0
;
}
$this
->
_seconds
=
$this
->
getTime
(
)
-
$time
;
}
/** ACCESSOR METHODS **/
/**
* Returns the time when message occured
*
@return
num
*/
public
function
getTime
(
)
{
return
$this
->
_time
;
}
/**
* Returns the message
*
@return
string
*/
public
function
getMessage
(
)
{
return
$this
->
_message
;
}
/**
* Returns the file
*
@return
string
*/
public
function
getFile
(
)
{
return
$this
->
_file
;
}
/**
* Returns the line number
*
@return
int
*/
public
function
getLine
(
)
{
return
$this
->
_line
;
}
/**
* Returns the function/method
*
@return
string
*/
public
function
getFunction
(
)
{
return
$this
->
_function
;
}
/**
* Returns the class name
*
@return
string
*/
public
function
getClass
(
)
{
return
$this
->
_class
;
}
/**
* Returns the time (in seconds) it took to execute the code from last message
*
@param
num
$time
last message time stamp
*
@return
num
*/
public
function
getSeconds
(
$time
=
null
)
{
$this
->
setSeconds
(
$time
)
;
return
$this
->
_seconds
;
}
}
?>