original_string: protected function addByUser(array $data)
      {
          $result = null;
          $this->hook->attach('rating.add.user.before', $data, $result, $this);
  
          if (isset($result)) {
              return (int) $result;
          }
  
          if (empty($data['rating'])) {
              return 0; // Do not add rating 0 (unvote)
          }
  
          $result = $this->db->insert('rating_user', $data);
          $this->hook->attach('rating.add.user.after', $data, $result, $this);
          return (int) $result;
      }
code: protected function addByUser(array $data)
      {
          $result = null;
          $this->hook->attach('rating.add.user.before', $data, $result, $this);
  
          if (isset($result)) {
              return (int) $result;
          }
  
          if (empty($data['rating'])) {
              return 0; // Do not add rating 0 (unvote)
          }
  
          $result = $this->db->insert('rating_user', $data);
          $this->hook->attach('rating.add.user.after', $data, $result, $this);
          return (int) $result;
      }
code_tokens: protected function addByUser ( array $ data ) { $ result = null ; $ this -> hook -> attach ( 'rating.add.user.before' , $ data , $ result , $ this ) ; if ( isset ( $ result ) ) { return ( int ) $ result ; } if ( empty ( $ data [ 'rating' ] ) ) { return 0 ; // Do not add rating 0 (unvote) } $ result = $ this -> db -> insert ( 'rating_user' , $ data ) ; $ this -> hook -> attach ( 'rating.add.user.after' , $ data , $ result , $ this ) ; return ( int ) $ result ; }
docstring: Adds a user rating
  @param array $data
  @return integer
docstring_tokens: Adds a user rating