<commit_before><?php
/**
 * This code is free software; you can redistribute it and/or modify it under
 * the terms of the new BSD License.
 *
 * Copyright (c) 2008-2009, <NAME>
 *
 * @author     <NAME>
 * @license    http://www.opensource.org/licenses/bsd-license.php New BSD License
 * @package    Steam Condenser (PHP)
 * @subpackage Steam Community
 */

require_once 'exceptions/SteamCondenserException.php';
require_once 'steam/community/GameStats.php';
require_once 'steam/community/SteamGroup.php';

/**
 * @package Steam Condenser (PHP)
 * @subpackage Steam Community
 */
class SteamId {

    /**
     * @var array
     */
    public static $steamIds = array();

    /**
     * @var String
     */
    private $customUrl;

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

    /**
     * @var array
     */
    private $friends;

    /**
     * @var array
     */
    private $games;

    /**
     * @var String
     */
    private $nickname;

    /**
     * @var String
     */
    private $steamId64;

    /**
     * Returns whether the requested SteamID is already cached
     * @param String id
     */
    public static function isCached($id) {
        return array_key_exists(strtolower($id), self::$steamIds);
    }

    /**
     * Clears the group cache
     */
    public static function clearCache() {
        self::$steamIds = array();
    }

    /**
     * Converts the SteamID as reported by game servers to a 64bit SteamID
     * @return String
     */
    public static function convertSteamIdToCommunityId($steamId) {
        if($steamId == 'STEAM_ID_LAN' || $steamId == 'BOT') {
            throw new SteamCondenserException("Cannot convert SteamID \"$steamId\" to a community ID.");
        }
        if(preg_match('/^STEAM_[0-1]:[0-1]:[0-9]+$/', $steamId) == 0) {
            throw new SteamCondenserException("SteamID \"$steamId\" doesn't have the correct format.");
        }

        $steamId = explode(':', substr($steamId, 6));
        $steamId = $steamId[1] + $steamId[2] * 2 + 76561197960265728;

        return number_format($steamId, 0, '', '');
    }

    /**
     * This checks the cache for an existing SteamID. If it exists it is returned.
     * Otherwise a new SteamID is created.
     * @param String $id
     * @param boolean $fetch
     * @param boolean $bypassCache
     * @return SteamId
     */
    public static function create($id, $fetch = true, $bypassCache = false) {
        $id = strtolower($id);
        if(self::isCached($id) && !$bypassCache) {<commit_msg>PHP: Fixed conversion of Steam IDs from STEAM_ID format into 64bit integers on 32bit systems<commit_after><?php
/**
 * This code is free software; you can redistribute it and/or modify it under
 * the terms of the new BSD License.
 *
 * Copyright (c) 2008-2009, <NAME>
 *
 * @author     <NAME>
 * @license    http://www.opensource.org/licenses/bsd-license.php New BSD License
 * @package    Steam Condenser (PHP)
 * @subpackage Steam Community
 */

require_once 'exceptions/SteamCondenserException.php';
require_once 'steam/community/GameStats.php';
require_once 'steam/community/SteamGroup.php';

/**
 * @package Steam Condenser (PHP)
 * @subpackage Steam Community
 */
class SteamId {

    /**
     * @var array
     */
    public static $steamIds = array();

    /**
     * @var String
     */
    private $customUrl;

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

    /**
     * @var array
     */
    private $friends;

    /**
     * @var array
     */
    private $games;

    /**
     * @var String
     */
    private $nickname;

    /**
     * @var String
     */
    private $steamId64;

    /**
     * Returns whether the requested SteamID is already cached
     * @param String id
     */
    public static function isCached($id) {
        return array_key_exists(strtolower($id), self::$steamIds);
    }

    /**
     * Clears the group cache
     */
    public static function clearCache() {
        self::$steamIds = array();
    }

    /**
     * Converts the SteamID as reported by game servers to a 64bit SteamID
     * @return String
     */
    public static function convertSteamIdToCommunityId($steamId) {
        if($steamId == 'STEAM_ID_LAN' || $steamId == 'BOT') {
            throw new SteamCondenserException("Cannot convert SteamID \"$steamId\" to a community ID.");
        }
        if(preg_match('/^STEAM_[0-1]:[0-1]:[0-9]+$/', $steamId) == 0) {
            throw new SteamCondenserException("SteamID \"$steamId\" doesn't have the correct format.");
        }

        $steamId = explode(':', substr($steamId, 6));
        $steamId = $steamId[1] + $steamId[2] * 2 + 1197960265728;

        return '7656' . $steamId;
    }

    /**
     * This checks the cache for an existing SteamID. If it exists it is returned.
     * Otherwise a new SteamID is created.
     * @param String $id
     * @param boolean $fetch
     * @param boolean $bypassCache
     * @return SteamId
     */
    public static function create($id, $fetch = true, $bypassCache = false) {
        $id = strtolower($id);
        if(self::isCached($id) && !$bypassCache) {
{'fraction_non_alphanumeric': 0.13431372549019607, 'fraction_numerical': 0.016666666666666666, 'mean_word_length': 2.371447455386649, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '1532604', 'n_tokens_mistral': 1688, 'n_tokens_neox': 1597, 'n_words': 436}