src/Krucas/Counter/Counter.php
protected function getForPeriod($key, \DatePeriod $period)
    {
        $ranges = $this->getRanges($period);

        if (count($ranges) > 0) {
            if (count($ranges) == 1 && !($ranges[0] instanceof DateRange)) {
                return new DateValue($ranges[0], $this->repository->getFor($key, $ranges[0]));
            }

            $values = array();

            /** @var \Krucas\Counter\DateRange $range */
            foreach ($ranges as $range) {
                $values[] = new RangeValue(
                    $range,
                    $this->repository->getForRange($key, $range->getStartDate(), $range->getEndDate())
                );
            }

            return $values;
        }

        return null;
    }
protected function getForPeriod($key, \DatePeriod $period)
    {
        $ranges = $this->getRanges($period);

        if (count($ranges) > 0) {
            if (count($ranges) == 1 && !($ranges[0] instanceof DateRange)) {
                return new DateValue($ranges[0], $this->repository->getFor($key, $ranges[0]));
            }

            $values = array();

            /** @var \Krucas\Counter\DateRange $range */
            foreach ($ranges as $range) {
                $values[] = new RangeValue(
                    $range,
                    $this->repository->getForRange($key, $range->getStartDate(), $range->getEndDate())
                );
            }

            return $values;
        }

        return null;
    }
protected function getForPeriod ( $ key , \ DatePeriod $ period ) { $ ranges = $ this -> getRanges ( $ period ) ; if ( count ( $ ranges ) > 0 ) { if ( count ( $ ranges ) == 1 && ! ( $ ranges [ 0 ] instanceof DateRange ) ) { return new DateValue ( $ ranges [ 0 ] , $ this -> repository -> getFor ( $ key , $ ranges [ 0 ] ) ) ; } $ values = array ( ) ; /** @var \Krucas\Counter\DateRange $range */ foreach ( $ ranges as $ range ) { $ values [ ] = new RangeValue ( $ range , $ this -> repository -> getForRange ( $ key , $ range -> getStartDate ( ) , $ range -> getEndDate ( ) ) ) ; } return $ values ; } return null ; }
Return value for a given period.

@param string $key Counter key.
@param \DatePeriod $period Date period.
@return \Krucas\Counter\Contracts\Value|array|null
Return value for a given period .