<commit_before><?php

namespace Moxl\Stanza;

class Avatar {
    static function get($to)
    {
        $dom = new \DOMDocument('1.0', 'UTF-8');
        $pubsub = $dom->createElementNS('http://jabber.org/protocol/pubsub', 'pubsub');

        $items = $dom->createElement('items');
        $items->setAttribute('node', 'urn:xmpp:avatar:data');
        $pubsub->appendChild($items);

        $xml = \Moxl\API::iqWrapper($pubsub, $to, 'get');
        \Moxl\API::request($xml);
    }

    static function set($data)
    {
        $dom = new \DOMDocument('1.0', 'UTF-8');
        $pubsub = $dom->createElementNS('http://jabber.org/protocol/pubsub', 'pubsub');

        $publish = $dom->createElement('publish');
        $publish->setAttribute('node', 'urn:xmpp:avatar:data');
        $pubsub->appendChild($publish);

        $item = $dom->createElement('item');
        $item->setAttribute('id', sha1($data));
        $publish->appendChild($item);

        $data = $dom->createElementNS('urn:xmpp:avatar:data', 'data', $data);
        $item->appendChild($data);

        $xml = \Moxl\API::iqWrapper($pubsub, false, 'set');
        \Moxl\API::request($xml);
    }

    static function setMetadata($data)
    {
        $dom = new \DOMDocument('1.0', 'UTF-8');
        $pubsub = $dom->createElementNS('http://jabber.org/protocol/pubsub', 'pubsub');

        $publish = $dom->createElement('publish');
        $publish->setAttribute('node', 'urn:xmpp:avatar:metadata');
        $pubsub->appendChild($publish);

        $item = $dom->createElement('item');
        $item->setAttribute('id', sha1($data));
        $publish->appendChild($item);

        $metadata = $dom->createElementNS('urn:xmpp:avatar:data', 'metadata');
        $item->appendChild($metadata);

        $info = $dom->createElement('info');
        $info->setAttribute('height', '410');
        $info->setAttribute('width', '410');
        $info->setAttribute('type', 'image/jpeg');
        $info->setAttribute('id', sha1($data));
        $info->setAttribute('bytes', strlen(base64_decode($data)));
        $metadata->appendChild($info);

        $xml = \Moxl\API::iqWrapper($pubsub, false, 'set');
        \Moxl\API::request($xml);
    }
}<commit_msg>Fix a small mistake in XEP-0084<commit_after><?php

namespace Moxl\Stanza;

class Avatar {
    static function get($to)
    {
        $dom = new \DOMDocument('1.0', 'UTF-8');
        $pubsub = $dom->createElementNS('http://jabber.org/protocol/pubsub', 'pubsub');

        $items = $dom->createElement('items');
        $items->setAttribute('node', 'urn:xmpp:avatar:data');
        $pubsub->appendChild($items);

        $xml = \Moxl\API::iqWrapper($pubsub, $to, 'get');
        \Moxl\API::request($xml);
    }

    static function set($data)
    {
        $dom = new \DOMDocument('1.0', 'UTF-8');
        $pubsub = $dom->createElementNS('http://jabber.org/protocol/pubsub', 'pubsub');

        $publish = $dom->createElement('publish');
        $publish->setAttribute('node', 'urn:xmpp:avatar:data');
        $pubsub->appendChild($publish);

        $item = $dom->createElement('item');
        $item->setAttribute('id', sha1($data));
        $publish->appendChild($item);

        $data = $dom->createElementNS('urn:xmpp:avatar:data', 'data', $data);
        $item->appendChild($data);

        $xml = \Moxl\API::iqWrapper($pubsub, false, 'set');
        \Moxl\API::request($xml);
    }

    static function setMetadata($data)
    {
        $dom = new \DOMDocument('1.0', 'UTF-8');
        $pubsub = $dom->createElementNS('http://jabber.org/protocol/pubsub', 'pubsub');

        $publish = $dom->createElement('publish');
        $publish->setAttribute('node', 'urn:xmpp:avatar:metadata');
        $pubsub->appendChild($publish);

        $item = $dom->createElement('item');
        $item->setAttribute('id', sha1($data));
        $publish->appendChild($item);

        $metadata = $dom->createElementNS('urn:xmpp:avatar:metadata', 'metadata');
        $item->appendChild($metadata);

        $info = $dom->createElement('info');
        $info->setAttribute('height', '410');
        $info->setAttribute('width', '410');
        $info->setAttribute('type', 'image/jpeg');
        $info->setAttribute('id', sha1($data));
        $info->setAttribute('bytes', strlen(base64_decode($data)));
        $metadata->appendChild($info);

        $xml = \Moxl\API::iqWrapper($pubsub, false, 'set');
        \Moxl\API::request($xml);
    }
}
{'fraction_non_alphanumeric': 0.2087837837837838, 'fraction_numerical': 0.00990990990990991, 'mean_word_length': 3.063129002744739, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 61, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 12}, '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': '4980973', 'n_tokens_mistral': 1418, 'n_tokens_neox': 1392, 'n_words': 199}