public function timeTo(string $time): Date
    {
        $times = explode(':', $time);
        if (count($times) != 3) {
            throw new \InvalidArgumentException(
                    'Given time "' . $time . '" does not follow required format HH:MM:SS'
            );
        }

        list($hour, $minute, $second) = $times;
        if (!ctype_digit($hour) || 0 > $hour || 23 < $hour) {
            throw new \InvalidArgumentException(
                    'Given value ' . $hour . ' for hour not suitable for changing the time.'
            );
        }

        if (!ctype_digit($minute) || 0 > $minute || 59 < $minute) {
            throw new \InvalidArgumentException(
                    'Given value ' . $minute . ' for minute not suitable for changing the time.'
            );
        }

        if (!ctype_digit($second) || 0 > $second || 59 < $second) {
            throw new \InvalidArgumentException(
                    'Given value ' . $second . ' for second not suitable for changing the time.'
            );
        }

        return $this->createDateWithNewTime((int) $hour, (int) $minute, (int) $second);
    }
public function timeTo(string $time): Date
    {
        $times = explode(':', $time);
        if (count($times) != 3) {
            throw new \InvalidArgumentException(
                    'Given time "' . $time . '" does not follow required format HH:MM:SS'
            );
        }

        list($hour, $minute, $second) = $times;
        if (!ctype_digit($hour) || 0 > $hour || 23 < $hour) {
            throw new \InvalidArgumentException(
                    'Given value ' . $hour . ' for hour not suitable for changing the time.'
            );
        }

        if (!ctype_digit($minute) || 0 > $minute || 59 < $minute) {
            throw new \InvalidArgumentException(
                    'Given value ' . $minute . ' for minute not suitable for changing the time.'
            );
        }

        if (!ctype_digit($second) || 0 > $second || 59 < $second) {
            throw new \InvalidArgumentException(
                    'Given value ' . $second . ' for second not suitable for changing the time.'
            );
        }

        return $this->createDateWithNewTime((int) $hour, (int) $minute, (int) $second);
    }
public function timeTo ( string $ time ) : Date { $ times = explode ( ':' , $ time ) ; if ( count ( $ times ) != 3 ) { throw new \ InvalidArgumentException ( 'Given time "' . $ time . '" does not follow required format HH:MM:SS' ) ; } list ( $ hour , $ minute , $ second ) = $ times ; if ( ! ctype_digit ( $ hour ) || 0 > $ hour || 23 < $ hour ) { throw new \ InvalidArgumentException ( 'Given value ' . $ hour . ' for hour not suitable for changing the time.' ) ; } if ( ! ctype_digit ( $ minute ) || 0 > $ minute || 59 < $ minute ) { throw new \ InvalidArgumentException ( 'Given value ' . $ minute . ' for minute not suitable for changing the time.' ) ; } if ( ! ctype_digit ( $ second ) || 0 > $ second || 59 < $ second ) { throw new \ InvalidArgumentException ( 'Given value ' . $ second . ' for second not suitable for changing the time.' ) ; } return $ this -> createDateWithNewTime ( ( int ) $ hour , ( int ) $ minute , ( int ) $ second ) ; }
returns a new date instance with same date but changed time

@api
@param   string  $time  time representation in format HH:MM:SS
@return  \stubbles\date\Date
@throws  \InvalidArgumentException
returns a new date instance with same date but changed time