<commit_before><?php
/**
 * @title          Visitor Model
 *
 * @author         <NAME> <<EMAIL>>
 * @copyright      (c) 2012-2018, <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 / User / Model
 * @version        1.1
 */

namespace PH7;

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

class VisitorModel
{
    /** @var int */
    private $iProfileId;

    /** @var int */
    private $iVisitorId;

    /** @var string */
    private $sDateVisit;

    /**
     * Assignment of attributes.
     *
     * @param int $iProfileId Profile ID.
     * @param int $iVisitorId ID User ID (visitor). Default NULL (this attribute is null only for the get method).
     * @param string $sDateVisit The date of last visit. Default NULL (this attribute is null only for the get method).
     */
    public function __construct($iProfileId, $iVisitorId = null, $sDateVisit = null)
    {
        $this->iProfileId = (int)$iProfileId;
        $this->iVisitorId = (int)$iVisitorId;
        $this->sDateVisit = $sDateVisit;
    }

    /**
     * Checks if the profile has already been visited by this user.
     *
     * @return bool Returns TRUE if the profile has already been seen, otherwise FALSE.
     */
    public function already()
    {
        $rStmt = Db::getInstance()->prepare('SELECT * FROM' . Db::prefix('MembersWhoViews') .
            'WHERE profileId = :profileId AND visitorId = :visitorId LIMIT 1');

        $rStmt->bindValue(':profileId', $this->iProfileId, \PDO::PARAM_INT);
        $rStmt->bindValue(':visitorId', $this->iVisitorId, \PDO::PARAM_INT);
        $rStmt->execute();

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

    /**
     * Gets Viewed Profile.
     *
     * @param int|string $mLooking Integer for visitor ID or string for a keyword
     * @param bool $bCount Put 'true' for count visitors or 'false' for the result of visitors.
     * @param string $sOrderBy
     * @param int $iSort
     * @param int $iOffset
     * @param int $iLimit
     *
     * @return int|stdClass An object for the visitors list or an integer for the total number visitors returned
     */
    public function get($mLooking, $bCount, $sOrderBy, $iSort, $iOffset, $iLimit)
    {
        $bCount = (bool)$bCount;
        $iOffset = (int)$iOffset;
        $iLimit = (int)$iLimit;
        $mLooking = trim($mLooking);

        $sSqlLimit = (!$bCount) ? 'LIMIT :offset, :limit' : '';
        $sSqlSelect = (!$bCount) ? '*' : 'COUNT(who.profileId) AS totalVisitors';

        if (ctype_digit($mLooking)) {
            $sSqlWhere = '(who.visitorId = :looking)';
        } else {
            $sSqlWhere = '(m.username LIKE :looking OR m.firstName LIKE :looking OR m.lastName LIKE :looking OR m.email LIKE :looking)';<commit_msg>Dont need else{} block. Assign $sSqlWhere for default value<commit_after><?php
/**
 * @title          Visitor Model
 *
 * @author         <NAME> <<EMAIL>>
 * @copyright      (c) 2012-2018, <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 / User / Model
 * @version        1.1
 */

namespace PH7;

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

class VisitorModel
{
    /** @var int */
    private $iProfileId;

    /** @var int */
    private $iVisitorId;

    /** @var string */
    private $sDateVisit;

    /**
     * Assignment of attributes.
     *
     * @param int $iProfileId Profile ID.
     * @param int $iVisitorId ID User ID (visitor). Default NULL (this attribute is null only for the get method).
     * @param string $sDateVisit The date of last visit. Default NULL (this attribute is null only for the get method).
     */
    public function __construct($iProfileId, $iVisitorId = null, $sDateVisit = null)
    {
        $this->iProfileId = (int)$iProfileId;
        $this->iVisitorId = (int)$iVisitorId;
        $this->sDateVisit = $sDateVisit;
    }

    /**
     * Checks if the profile has already been visited by this user.
     *
     * @return bool Returns TRUE if the profile has already been seen, otherwise FALSE.
     */
    public function already()
    {
        $rStmt = Db::getInstance()->prepare('SELECT * FROM' . Db::prefix('MembersWhoViews') .
            'WHERE profileId = :profileId AND visitorId = :visitorId LIMIT 1');

        $rStmt->bindValue(':profileId', $this->iProfileId, \PDO::PARAM_INT);
        $rStmt->bindValue(':visitorId', $this->iVisitorId, \PDO::PARAM_INT);
        $rStmt->execute();

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

    /**
     * Gets Viewed Profile.
     *
     * @param int|string $mLooking Integer for visitor ID or string for a keyword
     * @param bool $bCount Put 'true' for count visitors or 'false' for the result of visitors.
     * @param string $sOrderBy
     * @param int $iSort
     * @param int $iOffset
     * @param int $iLimit
     *
     * @return int|stdClass An object for the visitors list or an integer for the total number visitors returned
     */
    public function get($mLooking, $bCount, $sOrderBy, $iSort, $iOffset, $iLimit)
    {
        $bCount = (bool)$bCount;
        $iOffset = (int)$iOffset;
        $iLimit = (int)$iLimit;
        $mLooking = trim($mLooking);

        $sSqlLimit = (!$bCount) ? 'LIMIT :offset, :limit' : '';
        $sSqlSelect = (!$bCount) ? '*' : 'COUNT(who.profileId) AS totalVisitors';

        $sSqlWhere = '(m.username LIKE :looking OR m.firstName LIKE :looking OR m.lastName LIKE :looking OR m.email LIKE :looking)';
        if (ctype_digit($mLooking)) {
            $sSqlWhere = '(who.visitorId = :looking)';
{'fraction_non_alphanumeric': 0.1311704168847026, 'fraction_numerical': 0.005930577359148787, 'mean_word_length': 2.5548667079975202, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 33, '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': '4667326', 'n_tokens_mistral': 1817, 'n_tokens_neox': 1758, 'n_words': 542}