Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Steur <thomas.steur@googlemail.com>2014-09-30 09:37:32 +0400
committerThomas Steur <thomas.steur@googlemail.com>2014-09-30 09:37:32 +0400
commita00487b0b841c4b15463b591c7f62176c4b84d15 (patch)
tree6eb893ce356a4740e044c9cdadaf84ffb2095b9d /core/Period.php
parent0edef3332289a7cbe54b58084b967907d1086d29 (diff)
coding style fixes, some PHPStorm inspection fixes, improved readability of code, few refactorings, all as part of our code cleanup strategy
Diffstat (limited to 'core/Period.php')
-rw-r--r--core/Period.php19
1 files changed, 16 insertions, 3 deletions
diff --git a/core/Period.php b/core/Period.php
index 6898020ce7..1e3f188b5e 100644
--- a/core/Period.php
+++ b/core/Period.php
@@ -100,16 +100,20 @@ abstract class Period
public function getDateStart()
{
$this->generate();
+
if (count($this->subperiods) == 0) {
return $this->getDate();
}
+
$periods = $this->getSubperiods();
+
/** @var $currentPeriod Period */
$currentPeriod = $periods[0];
while ($currentPeriod->getNumberOfSubperiods() > 0) {
- $periods = $currentPeriod->getSubperiods();
+ $periods = $currentPeriod->getSubperiods();
$currentPeriod = $periods[0];
}
+
return $currentPeriod->getDate();
}
@@ -121,16 +125,20 @@ abstract class Period
public function getDateEnd()
{
$this->generate();
+
if (count($this->subperiods) == 0) {
return $this->getDate();
}
+
$periods = $this->getSubperiods();
+
/** @var $currentPeriod Period */
$currentPeriod = $periods[count($periods) - 1];
while ($currentPeriod->getNumberOfSubperiods() > 0) {
- $periods = $currentPeriod->getSubperiods();
+ $periods = $currentPeriod->getSubperiods();
$currentPeriod = $periods[count($periods) - 1];
}
+
return $currentPeriod->getDate();
}
@@ -212,10 +220,12 @@ abstract class Period
public function toString($format = "Y-m-d")
{
$this->generate();
+
$dateString = array();
foreach ($this->subperiods as $period) {
$dateString[] = $period->toString($format);
}
+
return $dateString;
}
@@ -259,6 +269,9 @@ abstract class Period
*/
public function getRangeString()
{
- return $this->getDateStart()->toString("Y-m-d") . "," . $this->getDateEnd()->toString("Y-m-d");
+ $dateStart = $this->getDateStart();
+ $dateEnd = $this->getDateEnd();
+
+ return $dateStart->toString("Y-m-d") . "," . $dateEnd->toString("Y-m-d");
}
}