src/Duration.php
public function dividedBy(int $divisor) : Duration
    {
        if ($divisor === 0) {
            throw new DateTimeException('Cannot divide a Duration by zero.');
        }

        if ($divisor === 1) {
            return $this;
        }

        $seconds = $this->seconds;
        $nanos = $this->nanos;

        if ($seconds < 0 && $nanos !== 0) {
            $seconds++;
            $nanos -= LocalTime::NANOS_PER_SECOND;
        }

        $remainder = $seconds % $divisor;
        $seconds = \intdiv($seconds, $divisor);

        $r1 = $nanos % $divisor;
        $nanos = \intdiv($nanos, $divisor);

        $r2 = LocalTime::NANOS_PER_SECOND % $divisor;
        $nanos += $remainder * \intdiv(LocalTime::NANOS_PER_SECOND, $divisor);
        $nanos += \intdiv($r1 + $remainder * $r2, $divisor);

        if ($nanos < 0) {
            $seconds--;
            $nanos = LocalTime::NANOS_PER_SECOND + $nanos;
        }

        return new Duration($seconds, $nanos);
    }
public function dividedBy(int $divisor) : Duration
    {
        if ($divisor === 0) {
            throw new DateTimeException('Cannot divide a Duration by zero.');
        }

        if ($divisor === 1) {
            return $this;
        }

        $seconds = $this->seconds;
        $nanos = $this->nanos;

        if ($seconds < 0 && $nanos !== 0) {
            $seconds++;
            $nanos -= LocalTime::NANOS_PER_SECOND;
        }

        $remainder = $seconds % $divisor;
        $seconds = \intdiv($seconds, $divisor);

        $r1 = $nanos % $divisor;
        $nanos = \intdiv($nanos, $divisor);

        $r2 = LocalTime::NANOS_PER_SECOND % $divisor;
        $nanos += $remainder * \intdiv(LocalTime::NANOS_PER_SECOND, $divisor);
        $nanos += \intdiv($r1 + $remainder * $r2, $divisor);

        if ($nanos < 0) {
            $seconds--;
            $nanos = LocalTime::NANOS_PER_SECOND + $nanos;
        }

        return new Duration($seconds, $nanos);
    }
public function dividedBy ( int $ divisor ) : Duration { if ( $ divisor === 0 ) { throw new DateTimeException ( 'Cannot divide a Duration by zero.' ) ; } if ( $ divisor === 1 ) { return $ this ; } $ seconds = $ this -> seconds ; $ nanos = $ this -> nanos ; if ( $ seconds < 0 && $ nanos !== 0 ) { $ seconds ++ ; $ nanos -= LocalTime :: NANOS_PER_SECOND ; } $ remainder = $ seconds % $ divisor ; $ seconds = \ intdiv ( $ seconds , $ divisor ) ; $ r1 = $ nanos % $ divisor ; $ nanos = \ intdiv ( $ nanos , $ divisor ) ; $ r2 = LocalTime :: NANOS_PER_SECOND % $ divisor ; $ nanos += $ remainder * \ intdiv ( LocalTime :: NANOS_PER_SECOND , $ divisor ) ; $ nanos += \ intdiv ( $ r1 + $ remainder * $ r2 , $ divisor ) ; if ( $ nanos < 0 ) { $ seconds -- ; $ nanos = LocalTime :: NANOS_PER_SECOND + $ nanos ; } return new Duration ( $ seconds , $ nanos ) ; }
Returns a copy of this Duration divided by the given value.

If this yields an inexact result, the result will be rounded down.

@param int $divisor

@return \Brick\DateTime\Duration

@throws DateTimeException If the divisor is zero.
Returns a copy of this Duration divided by the given value .