original_string: public function update(string $key, $data)
  	{
  		if (is_string($data)) {
  			$data = $this->normalizeToCollection($data);
  		}
  
  		if ($this->allowed->has($key)) {
  			$this->updatePreferencesForKey(
  				$key, $this->normalizedTags($data)
  			);
  
  			$this->updateCategories(
  				$data->pluck('category_id')->unique()
  			);
  		}
  
  		return $this;
  	}
code: public function update(string $key, $data)
  	{
  		if (is_string($data)) {
  			$data = $this->normalizeToCollection($data);
  		}
  
  		if ($this->allowed->has($key)) {
  			$this->updatePreferencesForKey(
  				$key, $this->normalizedTags($data)
  			);
  
  			$this->updateCategories(
  				$data->pluck('category_id')->unique()
  			);
  		}
  
  		return $this;
  	}
code_tokens: public function update ( string $ key , $ data ) { if ( is_string ( $ data ) ) { $ data = $ this -> normalizeToCollection ( $ data ) ; } if ( $ this -> allowed -> has ( $ key ) ) { $ this -> updatePreferencesForKey ( $ key , $ this -> normalizedTags ( $ data ) ) ; $ this -> updateCategories ( $ data -> pluck ( 'category_id' ) -> unique ( ) ) ; } return $ this ; }
docstring: Updates the user preferences for a given key and data.
  
  @param  string $key
  @param  mixed $data
  
  @return self
docstring_tokens: Updates the user preferences for a given key and data .