Scalr\Stats\CostAnalytics\Iterator\ChartQuarterlyIterator::current PHP Method

current() public method

See also: Iterator::current()
public current ( ) : Scalr\Stats\CostAnalytics\ChartPointInfo
return Scalr\Stats\CostAnalytics\ChartPointInfo
    public function current()
    {
        if (!isset($this->c[$this->i])) {
            $chartPoint = new ChartPointInfo($this);
            $previousPeriodDt = clone $chartPoint->dt;
            $previousPeriodDt->sub($this->getPreviousPeriodInterval());
            $ddt = clone $chartPoint->dt;
            $ddt->modify('next saturday');
            if ($ddt > $chartPoint->end) {
                $ddt = $chartPoint->end;
            }
            $chartPoint->label = $chartPoint->dt->format('M j') . ' - ' . $ddt->format('M j');
            $chartPoint->key = \Scalr_Util_DateTime::yearweek($chartPoint->dt->format('Y-m-d'));
            $chartPoint->previousPeriodKey = \Scalr_Util_DateTime::yearweek($previousPeriodDt->format('Y-m-d'));
            $chartPoint->show = $chartPoint->i % 3 == 0 ? $chartPoint->dt->format('M j') : ($chartPoint->isLastPoint && $chartPoint->i % 3 > 1 ? $ddt->format('M j') : '');
            $this->c[$this->i] = $chartPoint;
        }
        return $this->c[$this->i];
    }
ChartQuarterlyIterator