original_string: public function updateFriend($friend)
      {
          try {
              if ($this->isBefriendedBy($friend)) {
                  if (!Podium::getInstance()->db->createCommand()->delete('{{%podium_user_friend}}', [
                          'user_id' => $friend,
                          'friend_id' => $this->id
                      ])->execute()) {
                      return false;
                  }
                  Log::info('User unfriended', $this->id, __METHOD__);
              } else {
                  if (!Podium::getInstance()->db->createCommand()->insert('{{%podium_user_friend}}', ['user_id' => $friend, 'friend_id' => $this->id])->execute()) {
                      return false;
                  }
                  Log::info('User befriended', $this->id, __METHOD__);
              }
              Podium::getInstance()->podiumCache->deleteElement('user.friends', $friend);
              return true;
          } catch (Exception $e) {
              Log::error($e->getMessage(), null, __METHOD__);
          }
          return false;
      }
code: public function updateFriend($friend)
      {
          try {
              if ($this->isBefriendedBy($friend)) {
                  if (!Podium::getInstance()->db->createCommand()->delete('{{%podium_user_friend}}', [
                          'user_id' => $friend,
                          'friend_id' => $this->id
                      ])->execute()) {
                      return false;
                  }
                  Log::info('User unfriended', $this->id, __METHOD__);
              } else {
                  if (!Podium::getInstance()->db->createCommand()->insert('{{%podium_user_friend}}', ['user_id' => $friend, 'friend_id' => $this->id])->execute()) {
                      return false;
                  }
                  Log::info('User befriended', $this->id, __METHOD__);
              }
              Podium::getInstance()->podiumCache->deleteElement('user.friends', $friend);
              return true;
          } catch (Exception $e) {
              Log::error($e->getMessage(), null, __METHOD__);
          }
          return false;
      }
code_tokens: public function updateFriend ( $ friend ) { try { if ( $ this -> isBefriendedBy ( $ friend ) ) { if ( ! Podium :: getInstance ( ) -> db -> createCommand ( ) -> delete ( '{{%podium_user_friend}}' , [ 'user_id' => $ friend , 'friend_id' => $ this -> id ] ) -> execute ( ) ) { return false ; } Log :: info ( 'User unfriended' , $ this -> id , __METHOD__ ) ; } else { if ( ! Podium :: getInstance ( ) -> db -> createCommand ( ) -> insert ( '{{%podium_user_friend}}' , [ 'user_id' => $ friend , 'friend_id' => $ this -> id ] ) -> execute ( ) ) { return false ; } Log :: info ( 'User befriended' , $ this -> id , __METHOD__ ) ; } Podium :: getInstance ( ) -> podiumCache -> deleteElement ( 'user.friends' , $ friend ) ; return true ; } catch ( Exception $ e ) { Log :: error ( $ e -> getMessage ( ) , null , __METHOD__ ) ; } return false ; }
docstring: Updates friend status for the user.
  @param int $friend
  @return bool
  @since 0.2
docstring_tokens: Updates friend status for the user .