<commit_before><?php
// Timezone required since PHP 5.4
date_default_timezone_set('UTC');

// Include the Composer autoloader
include 'vendor/autoload.php';

// Shortcut for the FQN
use HabboAPI\Entities\Badge;
use HabboAPI\Entities\Habbo;
use HabboAPI\Entities\Photo;
use HabboAPI\Entities\Profile;
use HabboAPI\HabboAPI;
use HabboAPI\HabboParser;

// Create new Parser and API instance
$habboParser = new HabboParser('com');
$habboApi = new HabboAPI($habboParser);

// Find the user 'koeientemmer' and get their ID
try {
    $myHabbo = $habboApi->getHabbo('koeientemmer');
} catch (Exception $e) {
    echo '
        <p>Oops. Can not find this Habbo!</p>
        <p>Try to catch this exception gracefully in your application!</p>
        <p>[' . $e->getCode() . '] ' . $e->getMessage() . '</p>
        <hr>
        ' . $e->getTraceAsString() . '
    ';
    exit();
}

if ($myHabbo->hasProfile()) {
    // Collect all the profile info
    /** @var Profile $myProfile */
    $myProfile = $habboApi->getProfile($myHabbo->getId());
} else {
    // This Habbo has a closed home, only show their Habbo object
    $profile = new Profile();
    $myProfile = $profile->setHabbo($myHabbo);
}

// Get all their photos
$myPhotos = $habboApi->getPhotos($myHabbo->getId());

// Get extra information about one of their groups
// Note: This is actually a hardcoded group ID to showcase the parseGroup() endpoint
$group = $habboApi->getGroup("g-hhus-b0751bd6408cc83a8e046de6949fd747");

// Export as HTML
$html = [
    'habbo' => '',
    'worn_badges' => '',
    'friends' => '',
    'groups' => '',
    'rooms' => '',
    'badges' => '',
    'photos' => ''
];


// Some markup for the Habbo part

/* @var Habbo $habbo */
$habbo = $myProfile->getHabbo();
$html['habbo'] .= '<img src="http://www.habbo.com/habbo-imaging/avatarimage?figure=' . $habbo->getFigureString() . '&size=l&gesture=sml&head_direction=3"
            alt="' . $habbo->getHabboName() . '" title="' . $habbo->getHabboName() . '" style="float: left; margin-right: 10px;" />';
$html['habbo'] .= '<h3>' . $habbo->getHabboName() . '</h3>';
$html['habbo'] .= '<p>' . $habbo->getMotto() . '<br><em>' . $habbo->getMemberSince()->toFormattedDateString() . '</em></p>';
if ($habbo->getProfileVisible()) {
    $html['habbo'] .= '<p><a href="https://www.habbo.com/profile/' . $habbo->getHabboName() . '">View home &raquo;</a></p>';
}
if ($badges = $habbo->getSelectedBadges()) {
    foreach ($badges as $badge) {
        /** @var Badge $badge */
        $html['worn_badges'] .= '
            <div class="media">
                <div class="media-left media-middle">
                    <a href="#">
                        <img class="media-object" src="http://images.habbo.com/c_images/album1584/' . $badge->getCode() . '.gif" alt="' . $badge->getName() . '">
                    </a>
                </div>
                <div class="media-body">
                    <h4 class="media-heading">' . $badge->getName() . '</h4>
                    <em>' . $badge->getDescription() . '</em>
                </div>
            </div>
        ';
    }
}

// Show all the other sections as an unordered list
foreach (array("friends", "groups", "rooms", "badges") as $section) {
    $html[$section] .= '<ul>';
    $method_name = sprintf('get%s', ucfirst($section));
    foreach (call_user_func(array($myProfile, $method_name)) as $object) {
        $html[$section] .= '<li>' . $object . '</li>'; // uses the __toString() method
    }
    $html[$section] .= '</ul>';
}

// Generate the photos
if ($myPhotos) {
    /** @var Photo $myPhoto */
    foreach ($myPhotos as $myPhoto) {<commit_msg>Support closed profiles better in example.php<commit_after><?php
// Timezone required since PHP 5.4
date_default_timezone_set('UTC');

// Include the Composer autoloader
include 'vendor/autoload.php';

// Shortcut for the FQN
use HabboAPI\Entities\Badge;
use HabboAPI\Entities\Habbo;
use HabboAPI\Entities\Photo;
use HabboAPI\Entities\Profile;
use HabboAPI\HabboAPI;
use HabboAPI\HabboParser;

// Create new Parser and API instance
$habboParser = new HabboParser('com');
$habboApi = new HabboAPI($habboParser);

// Find the user 'koeientemmer' and get their ID
try {
    $myHabbo = $habboApi->getHabbo('koeientemmer');
} catch (Exception $e) {
    echo '
        <p>Oops. Can not find this Habbo!</p>
        <p>Try to catch this exception gracefully in your application!</p>
        <p>[' . $e->getCode() . '] ' . $e->getMessage() . '</p>
        <hr>
        ' . $e->getTraceAsString() . '
    ';
    exit();
}

if ($myHabbo->hasProfile()) {
    // Collect all the profile info
    /** @var Profile $myProfile */
    $myProfile = $habboApi->getProfile($myHabbo->getId());
} else {
    // This Habbo has a closed home, only show their Habbo object
    $myProfile = new Profile();
    $myProfile->setHabbo($myHabbo);
}

// Get all their photos
$myPhotos = $habboApi->getPhotos($myHabbo->getId());

// Get extra information about one of their groups
// Note: This is actually a hardcoded group ID to showcase the parseGroup() endpoint
$group = $habboApi->getGroup("g-hhus-b0751bd6408cc83a8e046de6949fd747");

// Export as HTML
$html = [
    'habbo' => '',
    'worn_badges' => '',
    'friends' => '',
    'groups' => '',
    'rooms' => '',
    'badges' => '',
    'photos' => ''
];


// Some markup for the Habbo part

/* @var Habbo $habbo */
$habbo = $myProfile->getHabbo();
$html['habbo'] .= '<img src="http://www.habbo.com/habbo-imaging/avatarimage?figure=' . $habbo->getFigureString() . '&size=l&gesture=sml&head_direction=3"
            alt="' . $habbo->getHabboName() . '" title="' . $habbo->getHabboName() . '" style="float: left; margin-right: 10px;" />';
$html['habbo'] .= '<h3>' . $habbo->getHabboName() . '</h3>';
$html['habbo'] .= '<p>' . $habbo->getMotto() . '<br><em>' . $habbo->getMemberSince()->toFormattedDateString() . '</em></p>';

if ($habbo->getProfileVisible()) {
    $html['habbo'] .= '<p><a href="https://www.habbo.com/profile/' . $habbo->getHabboName() . '">View home &raquo;</a></p>';
}

if ($badges = $habbo->getSelectedBadges()) {
    foreach ($badges as $badge) {
        /** @var Badge $badge */
        $html['worn_badges'] .= '
            <div class="media">
                <div class="media-left media-middle">
                    <a href="#">
                        <img class="media-object" src="http://images.habbo.com/c_images/album1584/' . $badge->getCode() . '.gif" alt="' . $badge->getName() . '">
                    </a>
                </div>
                <div class="media-body">
                    <h4 class="media-heading">' . $badge->getName() . '</h4>
                    <em>' . $badge->getDescription() . '</em>
                </div>
            </div>
        ';
    }
}

if ($myHabbo->hasProfile()) {
    // Show all the other sections as an unordered list
    foreach (array("friends", "groups", "rooms", "badges") as $section) {
        $html[$section] .= '<ul>';
        $method_name = sprintf('get%s', ucfirst($section));
        foreach (call_user_func(array($myProfile, $method_name)) as $object) {
            $html[$section] .= '<li>' . $object . '</li>'; // uses the __toString() method
        }
        $html[$section] .= '</ul>';
    }
}

// Generate the photos
if ($myPhotos) {
    /** @var Photo $myPhoto */
    foreach ($myPhotos as $myPhoto) {
{'fraction_non_alphanumeric': 0.19823008849557522, 'fraction_numerical': 0.009257998638529613, 'mean_word_length': 2.7517875383043924, 'pattern_counts': {'":': 0, '<': 77, '<?xml version=': 0, '>': 142, 'https://': 2, 'lorem ipsum': 0, 'www.': 4, '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': '44933', 'n_tokens_mistral': 2585, 'n_tokens_neox': 2510, 'n_words': 558}