models/classes/runner/time/QtiTimeLine.php
protected function computeRange($range)
    {
        // a range must be built from pairs of TimePoint
        if (count($range) % 2) {
            throw new IncompleteRangeException();
        }

        $duration = 0;
        $start = null;
        $end = null;
        foreach ($range as $point) {
            // grab the START TimePoint
            if ($this->isStartPoint($point)) {
                // we cannot have the START TimePoint twice
                if ($start) {
                    throw new MalformedRangeException('A time range must be defined by a START and a END TimePoint! Twice START found.');
                }
                $start = $point;
            }

            // grab the END TimePoint
            if ($this->isEndPoint($point)) {
                // we cannot have the END TimePoint twice
                if ($end) {
                    throw new MalformedRangeException('A time range must be defined by a START and a END TimePoint! Twice END found.');
                }
                $end = $point;
            }

            // when we have got START and END TimePoint, compute the duration
            if ($start && $end) {
                $duration += $this->getRangeDuration($start, $end);
                $start = null;
                $end = null;
            }
        }
        
        return $duration;
    }
protected function computeRange($range)
    {
        // a range must be built from pairs of TimePoint
        if (count($range) % 2) {
            throw new IncompleteRangeException();
        }

        $duration = 0;
        $start = null;
        $end = null;
        foreach ($range as $point) {
            // grab the START TimePoint
            if ($this->isStartPoint($point)) {
                // we cannot have the START TimePoint twice
                if ($start) {
                    throw new MalformedRangeException('A time range must be defined by a START and a END TimePoint! Twice START found.');
                }
                $start = $point;
            }

            // grab the END TimePoint
            if ($this->isEndPoint($point)) {
                // we cannot have the END TimePoint twice
                if ($end) {
                    throw new MalformedRangeException('A time range must be defined by a START and a END TimePoint! Twice END found.');
                }
                $end = $point;
            }

            // when we have got START and END TimePoint, compute the duration
            if ($start && $end) {
                $duration += $this->getRangeDuration($start, $end);
                $start = null;
                $end = null;
            }
        }
        
        return $duration;
    }
protected function computeRange ( $ range ) { // a range must be built from pairs of TimePoint if ( count ( $ range ) % 2 ) { throw new IncompleteRangeException ( ) ; } $ duration = 0 ; $ start = null ; $ end = null ; foreach ( $ range as $ point ) { // grab the START TimePoint if ( $ this -> isStartPoint ( $ point ) ) { // we cannot have the START TimePoint twice if ( $ start ) { throw new MalformedRangeException ( 'A time range must be defined by a START and a END TimePoint! Twice START found.' ) ; } $ start = $ point ; } // grab the END TimePoint if ( $ this -> isEndPoint ( $ point ) ) { // we cannot have the END TimePoint twice if ( $ end ) { throw new MalformedRangeException ( 'A time range must be defined by a START and a END TimePoint! Twice END found.' ) ; } $ end = $ point ; } // when we have got START and END TimePoint, compute the duration if ( $ start && $ end ) { $ duration += $ this -> getRangeDuration ( $ start , $ end ) ; $ start = null ; $ end = null ; } } return $ duration ; }
Compute the duration of a range of TimePoint
@param array $range
@return float
@throws IncompleteRangeException
@throws InconsistentRangeException
@throws MalformedRangeException
Compute the duration of a range of TimePoint