Scalr\Stats\CostAnalytics\Iterator\ChartDailyIterator::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());
            if ($chartPoint->interval == '1 hour') {
                $h = $chartPoint->dt->format('H');
                $chartPoint->label = $chartPoint->dt->format('l, M j, g A');
                $chartPoint->show = $h == 0 ? $chartPoint->dt->format('M j') : ($h % 3 == 0 ? $chartPoint->dt->format('g a') : '');
                $chartPoint->key = $chartPoint->dt->format("Y-m-d H:00:00");
                $chartPoint->previousPeriodKey = $previousPeriodDt->format('Y-m-d H:00:00');
            } else {
                if ($chartPoint->interval == '1 day') {
                    $chartPoint->label = $chartPoint->dt->format('M j');
                    $chartPoint->key = $chartPoint->dt->format('Y-m-d');
                    $chartPoint->previousPeriodKey = $previousPeriodDt->format('Y-m-d');
                    $chartPoint->show = $chartPoint->i % 4 == 0 || $chartPoint->isLastPoint && $chartPoint->i % 4 > 2 ? $chartPoint->dt->format('M j') : '';
                }
            }
            $this->c[$this->i] = $chartPoint;
        }
        return $this->c[$this->i];
    }
ChartDailyIterator