events[ $name ] = new StopWatchEvent(); } /** * Stop a named event. * * @param string $name Name of the event to stop. * @return StopWatchEvent Completed stopwatch event. * @throws InvalidStopwatchEvent If an unknown event name is provided. */ public function stop( $name ) { if ( ! array_key_exists( $name, $this->events ) ) { throw InvalidStopwatchEvent::from_name_to_stop( $name ); } $event = $this->events[ $name ]; $event->stop(); return $event; } }