original_string: public function get_module_instance(event_interface $event) {
          if (!$event->get_course_module()) {
              return null;
          }
  
          if (is_null($this->moduleinstances)) {
              $this->load_module_instances();
          }
  
          $id = $event->get_course_module()->get('instance');
          $name = $event->get_course_module()->get('modname');
  
          if (isset($this->moduleinstances[$name])) {
              if (isset($this->moduleinstances[$name][$id])) {
                  return $this->moduleinstances[$name][$id];
              }
          }
  
          return null;
      }
code: public function get_module_instance(event_interface $event) {
          if (!$event->get_course_module()) {
              return null;
          }
  
          if (is_null($this->moduleinstances)) {
              $this->load_module_instances();
          }
  
          $id = $event->get_course_module()->get('instance');
          $name = $event->get_course_module()->get('modname');
  
          if (isset($this->moduleinstances[$name])) {
              if (isset($this->moduleinstances[$name][$id])) {
                  return $this->moduleinstances[$name][$id];
              }
          }
  
          return null;
      }
code_tokens: public function get_module_instance ( event_interface $ event ) { if ( ! $ event -> get_course_module ( ) ) { return null ; } if ( is_null ( $ this -> moduleinstances ) ) { $ this -> load_module_instances ( ) ; } $ id = $ event -> get_course_module ( ) -> get ( 'instance' ) ; $ name = $ event -> get_course_module ( ) -> get ( 'modname' ) ; if ( isset ( $ this -> moduleinstances [ $ name ] ) ) { if ( isset ( $ this -> moduleinstances [ $ name ] [ $ id ] ) ) { return $ this -> moduleinstances [ $ name ] [ $ id ] ; } } return null ; }
docstring: Get the related module instance for a given event.
  
  @param event_interface $event The event object.
  @return stdClass|null
docstring_tokens: Get the related module instance for a given event .