Skip to content

Commit 8195ff4

Browse files
Call date() only once.
1 parent 65d1067 commit 8195ff4

File tree

4 files changed

+32
-16
lines changed

4 files changed

+32
-16
lines changed

PHP/CodeCoverage/Report/HTML.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,14 +132,17 @@ public function process(PHP_CodeCoverage $coverage, $target)
132132
$report = $coverage->getReport();
133133
unset($coverage);
134134

135+
$date = date('D M j G:i:s T Y', $_SERVER['REQUEST_TIME']);
136+
135137
$dashboard = new PHP_CodeCoverage_Report_HTML_Dashboard(
136-
$this->templatePath, $this->charset, $this->generator
138+
$this->templatePath, $this->charset, $this->generator, $date
137139
);
138140

139141
$directory = new PHP_CodeCoverage_Report_HTML_Directory(
140142
$this->templatePath,
141143
$this->charset,
142144
$this->generator,
145+
$date,
143146
$this->lowUpperBound,
144147
$this->highLowerBound
145148
);
@@ -148,6 +151,7 @@ public function process(PHP_CodeCoverage $coverage, $target)
148151
$this->templatePath,
149152
$this->charset,
150153
$this->generator,
154+
$date,
151155
$this->lowUpperBound,
152156
$this->highLowerBound,
153157
$this->highlight,

PHP/CodeCoverage/Report/HTML/Dashboard.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,18 +72,25 @@ class PHP_CodeCoverage_Report_HTML_Dashboard
7272
*/
7373
protected $generator;
7474

75+
/**
76+
* @var string
77+
*/
78+
protected $date;
79+
7580
/**
7681
* Constructor.
7782
*
7883
* @param string $templatePath
7984
* @param string $charset
8085
* @param string $generator
86+
* @param string $date
8187
*/
82-
public function __construct($templatePath, $charset, $generator)
88+
public function __construct($templatePath, $charset, $generator, $date)
8389
{
8490
$this->templatePath = $templatePath;
8591
$this->charset = $charset;
8692
$this->generator = $generator;
93+
$this->date = $date;
8794
}
8895

8996
/**
@@ -106,10 +113,7 @@ public function render(PHP_CodeCoverage_Report_Node_Directory $node, $file, $tit
106113
array(
107114
'title' => $title,
108115
'charset' => $this->charset,
109-
'date' => date(
110-
'D M j G:i:s T Y',
111-
$_SERVER['REQUEST_TIME']
112-
),
116+
'date' => $this->date,
113117
'version' => '@package_version@',
114118
'php_version' => PHP_VERSION,
115119
'generator' => $this->generator,

PHP/CodeCoverage/Report/HTML/Directory.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,11 @@ class PHP_CodeCoverage_Report_HTML_Directory
7272
*/
7373
protected $generator;
7474

75+
/**
76+
* @var string
77+
*/
78+
protected $date;
79+
7580
/**
7681
* @var integer
7782
*/
@@ -88,14 +93,16 @@ class PHP_CodeCoverage_Report_HTML_Directory
8893
* @param string $templatePath
8994
* @param string $charset
9095
* @param string $generator
96+
* @param string $date
9197
* @param integer $lowUpperBound
9298
* @param integer $highLowerBound
9399
*/
94-
public function __construct($templatePath, $charset, $generator, $lowUpperBound, $highLowerBound)
100+
public function __construct($templatePath, $charset, $generator, $date, $lowUpperBound, $highLowerBound)
95101
{
96102
$this->templatePath = $templatePath;
97103
$this->charset = $charset;
98104
$this->generator = $generator;
105+
$this->date = $date;
99106
$this->lowUpperBound = $lowUpperBound;
100107
$this->highLowerBound = $highLowerBound;
101108
}
@@ -119,10 +126,7 @@ public function render(PHP_CodeCoverage_Report_Node_Directory $node, $file, $tit
119126
'charset' => $this->charset,
120127
'low_upper_bound' => $this->lowUpperBound,
121128
'high_lower_bound' => $this->highLowerBound,
122-
'date' => date(
123-
'D M j G:i:s T Y',
124-
$_SERVER['REQUEST_TIME']
125-
),
129+
'date' => $this->date,
126130
'version' => '@package_version@',
127131
'php_version' => PHP_VERSION,
128132
'generator' => $this->generator

PHP/CodeCoverage/Report/HTML/File.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,11 @@ class PHP_CodeCoverage_Report_HTML_File
7272
*/
7373
protected $generator;
7474

75+
/**
76+
* @var string
77+
*/
78+
protected $date;
79+
7580
/**
7681
* @var integer
7782
*/
@@ -98,16 +103,18 @@ class PHP_CodeCoverage_Report_HTML_File
98103
* @param string $templatePath
99104
* @param string $charset
100105
* @param string $generator
106+
* @param string $date
101107
* @param integer $lowUpperBound
102108
* @param integer $highLowerBound
103109
* @param boolean $highlight
104110
* @param boolean $yui
105111
*/
106-
public function __construct($templatePath, $charset, $generator, $lowUpperBound, $highLowerBound, $highlight, $yui)
112+
public function __construct($templatePath, $charset, $generator, $date, $lowUpperBound, $highLowerBound, $highlight, $yui)
107113
{
108114
$this->templatePath = $templatePath;
109115
$this->charset = $charset;
110116
$this->generator = $generator;
117+
$this->date = $date;
111118
$this->lowUpperBound = $lowUpperBound;
112119
$this->highLowerBound = $highLowerBound;
113120
$this->highlight = $highlight;
@@ -137,10 +144,7 @@ public function render(PHP_CodeCoverage_Report_Node_File $node, $file, $title =
137144
array(
138145
'title' => $title,
139146
'charset' => $this->charset,
140-
'date' => date(
141-
'D M j G:i:s T Y',
142-
$_SERVER['REQUEST_TIME']
143-
),
147+
'date' => $this->date,
144148
'version' => '@package_version@',
145149
'php_version' => PHP_VERSION,
146150
'generator' => $this->generator

0 commit comments

Comments
 (0)