<commit_before><?php
namespace Pwnraid\Bnet\Warcraft\Auctions;

use Pwnraid\Bnet\Core\AbstractRequest;
use Pwnraid\Bnet\Utility;

class AuctionRequest extends AbstractRequest
{
    public function download(IndexEntity $index)
    {
        $data     = json_decode(file_get_contents($index->url), true);
        $auctions = [];

        foreach ($data['auctions']['auctions'] as $auction) {
            $auctions[] = new AuctionEntity($auction);
        }

        return $auctions;
    }

    public function index($realm)
    {
        $data = $this->client->get('auction/data/'.Utility::realmNameToSlug($realm));

        if ($data === null) {
            return null;
        }

        return new IndexEntity($data['files'][0]);
    }
}
<commit_msg>Error handler for weird Battle.net issue.<commit_after><?php
namespace Pwnraid\Bnet\Warcraft\Auctions;

use Pwnraid\Bnet\Core\AbstractRequest;
use Pwnraid\Bnet\Utility;

class AuctionRequest extends AbstractRequest
{
    public function download(IndexEntity $index)
    {
        $data = file_get_contents($index->url);

        if ($data === false) {
            throw new BattleNetException('Unable to download auction dump from "'.$index->url.'"');
        }

        $json     = json_decode($data, true);
        $auctions = [];

        if (is_array($json) === false) {
            throw new BattleNetException('Invalid json returned in auction dump from "'.$index->url.'"');
        }

        foreach ($json['auctions']['auctions'] as $auction) {
            $auctions[] = new AuctionEntity($auction);
        }

        return $auctions;
    }

    public function index($realm)
    {
        $data = $this->client->get('auction/data/'.Utility::realmNameToSlug($realm));

        if ($data === null) {
            return null;
        }

        return new IndexEntity($data['files'][0]);
    }
}

{'fraction_non_alphanumeric': 0.14316469321851452, 'fraction_numerical': 0.001076426264800861, 'mean_word_length': 2.581888246628131, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2876372', 'n_tokens_mistral': 558, 'n_tokens_neox': 554, 'n_words': 114}