Captioning\File::shift PHP 메소드

shift() 공개 메소드

Shifts a range of subtitles a specified amount of time.
public shift ( integer $_time, integer $_startIndex = null, integer $_endIndex = null )
$_time integer The time to use (ms), which can be positive or negative.
$_startIndex integer The subtitle index the range begins with.
$_endIndex integer The subtitle index the range ends with.
    public function shift($_time, $_startIndex = null, $_endIndex = null)
    {
        if (!is_int($_time)) {
            return false;
        }
        if ($_time == 0) {
            return true;
        }
        if (null === $_startIndex) {
            $_startIndex = 0;
        }
        if (null === $_endIndex) {
            $_endIndex = $this->getCuesCount() - 1;
        }
        $startCue = $this->getCue($_startIndex);
        $endCue = $this->getCue($_endIndex);
        //check subtitles do exist
        if (!$startCue || !$endCue) {
            return false;
        }
        for ($i = $_startIndex; $i <= $_endIndex; $i++) {
            $cue = $this->getCue($i);
            $cue->shift($_time);
        }
        return true;
    }