* @copyright Since 2007 PrestaShop SA and Contributors * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ namespace PrestaShop\Module\Ps_metrics\Kpi\Configuration; class KpiConfiguration { /** * @var array */ public $dateRange; /** * @var array */ public $granularity; /** * @var array */ public $compareDateRange = null; /** * @return array */ public function getDateRange() { return $this->dateRange; } /** * @param array $dateRange * * @return void */ public function setDateRange($dateRange) { $this->dateRange = $dateRange; } /** * @return array */ public function getGranularity() { return $this->granularity; } /** * @param string $granularity * * @return void */ public function setGranularity($granularity) { $this->granularity = $this->getGranularityForSqlDates($granularity); } /** * @return array */ public function getCompareDateRange() { return $this->compareDateRange; } /** * @param array $compareDateRange * * @return void */ public function setCompareDateRange($compareDateRange) { $this->compareDateRange = $compareDateRange; } /** * getGranularityForSqlDates * * @param string $granularity * * @return array */ private function getGranularityForSqlDates($granularity) { if ('weeks' === $granularity) { // for day : 0000-00-00 return [ 'type' => 'weeks', 'forSql' => 10, ]; } if ('months' === $granularity) { // for month : 0000-00 return [ 'type' => 'months', 'forSql' => 7, ]; } if ('hours' === $granularity) { // for hours : 0000-00-00 00 return [ 'type' => 'hours', 'forSql' => 13, ]; } // for day : 0000-00-00 return [ 'type' => 'days', 'forSql' => 10, ]; } }