Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
 
3
/*
4
 * This file is part of the symfony package.
5
 * (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
 
11
/**
12
 * sfTimerManager is a container for sfTimer objects.
13
 *
14
 * @package    symfony
15
 * @subpackage util
16
 * @author     Fabien Potencier <fabien.potencier@symfony-project.com>
17
 * @version    SVN: $Id: sfTimerManager.class.php 13339 2008-11-25 14:58:05Z fabien $
18
 */
19
class sfTimerManager
20
{
21
  static public $timers = array();
22
 
23
  /**
24
   * Gets a sfTimer instance.
25
   *
26
   * It returns the timer named $name or create a new one if it does not exist.
27
   *
28
   * @param string $name The name of the timer
29
   *
30
   * @return sfTimer The timer instance
31
   */
32
  public static function getTimer($name)
33
  {
34
    if (!isset(self::$timers[$name]))
35
    {
36
      self::$timers[$name] = new sfTimer($name);
37
    }
38
 
39
    self::$timers[$name]->startTimer();
40
 
41
    return self::$timers[$name];
42
  }
43
 
44
  /**
45
   * Gets all sfTimer instances stored in sfTimerManager.
46
   *
47
   * @return array An array of all sfTimer instances
48
   */
49
  public static function getTimers()
50
  {
51
    return self::$timers;
52
  }
53
 
54
  /**
55
   * Clears all sfTimer instances stored in sfTimerManager.
56
   */
57
  public static function clearTimers()
58
  {
59
    self::$timers = array();
60
  }
61
}