original_string: public function add(favourite $favourite) : favourite {
          global $DB;
          $this->validate($favourite);
          $favourite = (array)$favourite;
          $time = time();
          $favourite['timecreated'] = $time;
          $favourite['timemodified'] = $time;
          $id = $DB->insert_record($this->favouritetable, $favourite);
          return $this->find($id);
      }
code: public function add(favourite $favourite) : favourite {
          global $DB;
          $this->validate($favourite);
          $favourite = (array)$favourite;
          $time = time();
          $favourite['timecreated'] = $time;
          $favourite['timemodified'] = $time;
          $id = $DB->insert_record($this->favouritetable, $favourite);
          return $this->find($id);
      }
code_tokens: public function add ( favourite $ favourite ) : favourite { global $ DB ; $ this -> validate ( $ favourite ) ; $ favourite = ( array ) $ favourite ; $ time = time ( ) ; $ favourite [ 'timecreated' ] = $ time ; $ favourite [ 'timemodified' ] = $ time ; $ id = $ DB -> insert_record ( $ this -> favouritetable , $ favourite ) ; return $ this -> find ( $ id ) ; }
docstring: Add a favourite to the repository.
  
  @param favourite $favourite the favourite to add.
  @return favourite the favourite which has been stored.
  @throws \dml_exception if any database errors are encountered.
  @throws \moodle_exception if the favourite has missing or invalid properties.
docstring_tokens: Add a favourite to the repository .