Stat
[
class tree: Stat
] [
index: Stat
] [
all elements
]
Packages:
Analyzer
Base
Cache
Config
Container
Creator
Log
Memory
Pattern
Registry
Stat
Word
Source for file Stat.php
Documentation is available at
Stat.php
<?php
/**
* Mai_Stat
*
* Copyright (C) 2009 Mai (Me Artificial Intelligence)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*
@author
Wouter Bulten (wouterbulten@mai-ai.org)
*
@copyright
Copyright (C) 2009 Mai (Me Artificial Intelligence)
*
@license
http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
*
@link
http://www.launchpad.net/mai
*
*
@category
Mai
*
@package
Stat
*
*/
/**
* Mai_Stat is a statistics manager of Mai.
*
*
@author
Wouter Bulten (wouterbulten@mai-ai.org)
*
@copyright
Copyright (C) 2009 Mai (Me Artificial Intelligence)
*
@license
http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
*
@link
http://www.launchpad.net/mai
*
*
@category
Mai
*
@package
Stat
*
*/
class
Mai_Stat
{
/**
*
@var
Mai_Stat
Singleton instance
*/
protected
static
$_instance
;
/**
*
@var
integer
The start time.
*/
protected
static
$_timeStart
;
/**
*
*
@var
integer
The end time.
*/
protected
static
$_timeEnd
;
/**
*
@var
integer
Status of Mai_Stat
*/
protected
static
$_status
=
self
::
WAITING_FOR_START
;
/**
* Constants for the status of Mai_Stat
*/
const
WAITING_FOR_START
=
0
;
const
STARTED
=
1
;
const
ENDED
=
2
;
/**
* Private constructor to prevent creation of this object.
*
@return
void
*/
private
function
__construct
(
)
{
}
/**
* Retrieve singleton instance
*
*
@return
Mai_Stat
*/
public
static
function
getInstance
(
)
{
if
(
!
Mai
::
isInit
(
))
{
trigger_error
(
'Mai has not been setup yet. Please use Mai::init().'
,
E_USER_ERROR
)
;
}
if
(
null
===
self
::
$_instance
)
{
self
::
$_instance
=
new
self
(
)
;
}
return
self
::
$_instance
;
}
/**
* Start the statistics.
*
@return
void
*/
public
static
function
start
(
)
{
self
::
$_status
=
self
::
STARTED
;
//Get time in seconds
self
::
$_timeStart
=
microtime
(
true
)
;
}
/**
* Exit the statistics.
*
@return
void
*/
public
static
function
end
(
)
{
self
::
$_status
=
self
::
ENDED
;
//Get time in seconds
self
::
$_timeEnd
=
microtime
(
true
)
;
}
public
function
executionTime
(
)
{
if
(
self
::
$_status
==
self
::
ENDED
)
{
return
self
::
$_timeEnd
-
self
::
$_timeStart
;
}
else
{
trigger_error
(
"Mai_Stat not ended yet."
,
E_USER_NOTICE
)
;
}
}
/**
* Cloning of a singleton class is not allowed.
*
@return
void
*/
final
public
function
__clone
(
)
{
trigger_error
(
'Clone is not allowed.'
,
E_USER_ERROR
)
;
}
/**
* Function to prevent deserializing
*
@return
void
*/
public
function
__wakeup
(
)
{
trigger_error
(
'Deserializing is not allowed.'
,
E_USER_ERROR
)
;
}
}
Documentation generated on Mon, 27 Jul 2009 19:55:13 +0200 by
phpDocumentor 1.4.1