<commit_before><?php
/**
 * @author         <NAME> <<EMAIL>>
 * @copyright      (c) 2012-2017, <NAME>. All Rights Reserved.
 * @license        GNU General Public License; See PH7.LICENSE.txt and PH7.COPYRIGHT.txt in the root directory.
 * @package        PH7/ App / System / Module / Friend / Model
 */
namespace PH7;

use PH7\Framework\Mvc\Model\Engine\Db;

class FriendModel extends FriendCoreModel
{
    private $_sStatus;

    /**
     * Check exists in the friends list
     *
     * @param integer $iProfileId = user Id
     * @param integer $iFriendId friend id
     * @param mixed (integer or string) $mPending 'all' = select the friends that are approved and pending, 1 = approved or 0 = pending friend requests. Default value is 'all'
     * @param boolean
     */
    public function inList($iProfileId, $iFriendId, $mPending = 'all')
    {
        $iProfileId = (int) $iProfileId;
        $iFriendId = (int) $iFriendId;

        $sSqlPending = ($mPending !== 'all') ? 'AND pending = :pending' : '';

        $rStmt = Db::getInstance()->prepare('SELECT * FROM' . Db::prefix('MembersFriends') .
          'WHERE profileId = :profileId AND friendId = :friendId ' . $sSqlPending . ' LIMIT 1');

        $rStmt->bindValue(':profileId', $iProfileId, \PDO::PARAM_INT);
        $rStmt->bindValue(':friendId', $iFriendId, \PDO::PARAM_INT);
        if ($mPending !== 'all') {
            $rStmt->bindValue(':pending', $mPending, \PDO::PARAM_INT);
        }
        $rStmt->execute();
        return $rStmt->fetchColumn() > 0;
    }

    /**
     * Add a friend
     *<commit_msg>Fix wrong @return phpdoc tag<commit_after><?php
/**
 * @author         <NAME> <<EMAIL>>
 * @copyright      (c) 2012-2017, <NAME>. All Rights Reserved.
 * @license        GNU General Public License; See PH7.LICENSE.txt and PH7.COPYRIGHT.txt in the root directory.
 * @package        PH7/ App / System / Module / Friend / Model
 */
namespace PH7;

use PH7\Framework\Mvc\Model\Engine\Db;

class FriendModel extends FriendCoreModel
{
    private $_sStatus;

    /**
     * Check exists in the friends list
     *
     * @param integer $iProfileId
     * @param integer $iFriendId
     * @param integer|string $mPending 'all' = select the friends that are approved and pending, 1 = approved or 0 = pending friend requests. Default value is 'all'
     *
     * @return boolean
     */
    public function inList($iProfileId, $iFriendId, $mPending = 'all')
    {
        $iProfileId = (int) $iProfileId;
        $iFriendId = (int) $iFriendId;

        $sSqlPending = ($mPending !== 'all') ? 'AND pending = :pending' : '';

        $rStmt = Db::getInstance()->prepare('SELECT * FROM' . Db::prefix('MembersFriends') .
          'WHERE profileId = :profileId AND friendId = :friendId ' . $sSqlPending . ' LIMIT 1');

        $rStmt->bindValue(':profileId', $iProfileId, \PDO::PARAM_INT);
        $rStmt->bindValue(':friendId', $iFriendId, \PDO::PARAM_INT);
        if ($mPending !== 'all') {
            $rStmt->bindValue(':pending', $mPending, \PDO::PARAM_INT);
        }
        $rStmt->execute();

        return $rStmt->fetchColumn() > 0;
    }

    /**
     * Add a friend
     *
{'fraction_non_alphanumeric': 0.14706814580031696, 'fraction_numerical': 0.010776545166402536, 'mean_word_length': 2.6359447004608296, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2140264', 'n_tokens_mistral': 1008, 'n_tokens_neox': 997, 'n_words': 267}