Permalink
Browse files

Call date() only once.

  • Loading branch information...
sebastianbergmann committed Nov 21, 2006
1 parent 17532ea commit b4807392ebab1982cdb0cb0ca85fa3a68c454a7f
Showing with 24 additions and 3 deletions.
  1. +1 −1 PHPUnit/Util/Report/Coverage/Node.php
  2. +1 −1 PHPUnit/Util/Report/Test/Node.php
  3. +22 −1 PHPUnit/Util/Template.php
@@ -254,7 +254,7 @@ protected function setTemplateVars(PHPUnit_Util_Template $template, $title)
$this->getNumExecutableLines(),
$this->getNumExecutedLines(),
$this->getExecutedPercent(),
- date('D M j G:i:s T Y'),
+ $template->getDate(),
PHPUnit_Runner_Version::id(),
phpversion('xdebug')
)
@@ -163,7 +163,7 @@ protected function setTemplateVars(PHPUnit_Util_Template $template, $title)
array(
$title,
$this->getLink(TRUE),
- date('D M j G:i:s T Y'),
+ $template->getDate(),
PHPUnit_Runner_Version::id(),
phpversion('xdebug')
)
View
@@ -63,7 +63,13 @@
class PHPUnit_Util_Template
{
/**
- * @var array
+ * @var string
+ * @access private
+ */
+ private static $date = '';
+
+ /**
+ * @var string
* @access private
*/
private $template = '';
@@ -152,5 +158,20 @@ public function renderTo($target) {
throw new RuntimeException('Could not write to ' . $target . '.');
}
}
+
+ /**
+ * Returns the cached result of date('D M j G:i:s T Y').
+ *
+ * @return string
+ * @access public
+ * @since Method available since Release 3.1.0
+ */
+ public static function getDate() {
+ if (self::$date == '') {
+ self::$date = date('D M j G:i:s T Y');
+ }
+
+ return self::$date;
+ }
}
?>

0 comments on commit b480739

Please sign in to comment.