<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) 2010, <NAME>
 *
 * @author     <NAME>
 * @license    http://www.opensource.org/licenses/bsd-license.php New BSD License
 * @package    Steam Condenser (PHP)
 * @subpackage Steam Community
 */

require_once STEAM_CONDENSER_PATH . 'steam/community/WebApi.php';

/**
 * The AppNews class is a representation of Steam news and can be used to load
 * current news about specific games
 *
 * @package Steam Condenser (PHP)
 * @subpackage Steam Community
 */
class AppNews {

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

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

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

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

    /**
     * @var bool
     */
    private $external;

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

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

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

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

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

    /**
     * Loads the news for the given game with the given restrictions
     *
     * @param int appId The unique Steam Application ID of the game (e.g. 440
     *                  for Team Fortress 2). See
     *                  http://developer.valvesoftware.com/wiki/Steam_Application_IDs
     *                  for all application IDs
     * @param int count The maximum number of news to load (default: 5).
     *                  There's no reliable way to load all news. Use really a
     *                  really great number instead
     * @param int maxLength The maximum content length of the news (default:
     *                      null). If a maximum length is defined, the content
     *                      of the news will only be at most maxLength
     *                      characters long plus an ellipsis
     * @return AppNews[] An array of news items for the specified game with the
     *                   given options
     */
    public static function getNewsForApp($appId, $count = 5, $maxLength = null) {
        $params = array('appid' => $appId, 'count' => $count,
                        'maxlength' => $maxLength);
        $data = json_decode(WebApi::getJSON('ISteamNews', 'GetNewsForApp', 1, $params));

        $newsItems = array();
        foreach($data->appnews->newsitems->newsitem as $newsData) {
            $newsItems[] = new AppNews($appId, $newsData);
        }

        return $newsItems;
    }

    /**
     * Creates a new instance of an AppNews news item with the given data
     *
     * @param int appId The unique Steam Application ID of the game (e.g. 440
     *                  for Team Fortress 2). See
     *                  http://developer.valvesoftware.com/wiki/Steam_Application_IDs
     *                  for all application IDs
     * @param stdClass newsData The news data extracted from JSON
     */
    private function __construct($appId, $newsData) {
        $this->appId     = $appId;
        $this->author    = $newsData->author;
        $this->contents  = trim($newsData->contents);
        $this->date      = (int) $newsData->date;
        $this->external  = (bool) $newsData->is_external_url;
        $this->feedLabel = $newsData->feedlabel;
        $this->feedName  = $newsData->feedname;<commit_msg>Updated AppNews Web API to version 2<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) 2010-2011, <NAME>
 *
 * @author     <NAME>
 * @license    http://www.opensource.org/licenses/bsd-license.php New BSD License
 * @package    Steam Condenser (PHP)
 * @subpackage Steam Community
 */

require_once STEAM_CONDENSER_PATH . 'steam/community/WebApi.php';

/**
 * The AppNews class is a representation of Steam news and can be used to load
 * current news about specific games
 *
 * @package Steam Condenser (PHP)
 * @subpackage Steam Community
 */
class AppNews {

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

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

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

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

    /**
     * @var bool
     */
    private $external;

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

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

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

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

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

    /**
     * Loads the news for the given game with the given restrictions
     *
     * @param int appId The unique Steam Application ID of the game (e.g. 440
     *                  for Team Fortress 2). See
     *                  http://developer.valvesoftware.com/wiki/Steam_Application_IDs
     *                  for all application IDs
     * @param int count The maximum number of news to load (default: 5).
     *                  There's no reliable way to load all news. Use really a
     *                  really great number instead
     * @param int maxLength The maximum content length of the news (default:
     *                      null). If a maximum length is defined, the content
     *                      of the news will only be at most maxLength
     *                      characters long plus an ellipsis
     * @return AppNews[] An array of news items for the specified game with the
     *                   given options
     */
    public static function getNewsForApp($appId, $count = 5, $maxLength = null) {
        $params = array('appid' => $appId, 'count' => $count,
                        'maxlength' => $maxLength);
        $data = json_decode(WebApi::getJSON('ISteamNews', 'GetNewsForApp', 2, $params));

        $newsItems = array();
        foreach($data->appnews->newsitems as $newsData) {
            $newsItems[] = new AppNews($appId, $newsData);
        }

        return $newsItems;
    }

    /**
     * Creates a new instance of an AppNews news item with the given data
     *
     * @param int appId The unique Steam Application ID of the game (e.g. 440
     *                  for Team Fortress 2). See
     *                  http://developer.valvesoftware.com/wiki/Steam_Application_IDs
     *                  for all application IDs
     * @param stdClass newsData The news data extracted from JSON
     */
    private function __construct($appId, $newsData) {
        $this->appId     = $appId;
        $this->author    = $newsData->author;
        $this->contents  = trim($newsData->contents);
        $this->date      = (int) $newsData->date;
        $this->external  = (bool) $newsData->is_external_url;
        $this->feedLabel = $newsData->feedlabel;
        $this->feedName  = $newsData->feedname;
{'fraction_non_alphanumeric': 0.10771658060814687, 'fraction_numerical': 0.0050200803212851405, 'mean_word_length': 1.8357055713704757, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 44, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3722180', 'n_tokens_mistral': 2037, 'n_tokens_neox': 1941, 'n_words': 639}