original_string: public function set(array $data)
      {
          $result = null;
          $this->hook->attach('rating.set.before', $data, $result, $this);
  
          if (isset($result)) {
              return $result;
          }
  
          $conditions = array(
              'user_id' => $data['user_id'],
              'product_id' => $data['product_id']
          );
  
          $this->db->delete('rating_user', $conditions);
  
          $this->addByUser($data);
  
          $result = $this->setBayesian($data);
          $this->hook->attach('rating.set.after', $data, $result, $this);
          return $result;
      }
code: public function set(array $data)
      {
          $result = null;
          $this->hook->attach('rating.set.before', $data, $result, $this);
  
          if (isset($result)) {
              return $result;
          }
  
          $conditions = array(
              'user_id' => $data['user_id'],
              'product_id' => $data['product_id']
          );
  
          $this->db->delete('rating_user', $conditions);
  
          $this->addByUser($data);
  
          $result = $this->setBayesian($data);
          $this->hook->attach('rating.set.after', $data, $result, $this);
          return $result;
      }
code_tokens: public function set ( array $ data ) { $ result = null ; $ this -> hook -> attach ( 'rating.set.before' , $ data , $ result , $ this ) ; if ( isset ( $ result ) ) { return $ result ; } $ conditions = array ( 'user_id' => $ data [ 'user_id' ] , 'product_id' => $ data [ 'product_id' ] ) ; $ this -> db -> delete ( 'rating_user' , $ conditions ) ; $ this -> addByUser ( $ data ) ; $ result = $ this -> setBayesian ( $ data ) ; $ this -> hook -> attach ( 'rating.set.after' , $ data , $ result , $ this ) ; return $ result ; }
docstring: Sets a rating for the given user and product
  @param array $data
  @return array
docstring_tokens: Sets a rating for the given user and product