<commit_before><?php
namespace Lethe;

/**
* Lethe\Format - data formatter, provides basic format and clenaup methods
* @author <NAME> aka prochor <<EMAIL>>
* @version 1.2
*/
class Format
{
    /**
    * @ignore
    */
    final public function __construct(){}

    /**
     * Force to int
     * @param string $var
     * @return int
    */
    public static function makeInt($var)
    {
      return (int)$var;
    }

    /**
     * Force to float
     * @param string $var
     * @return float
    */
    public static function makeFloat($var)
    {
      return  (float)str_replace(',', '.', $var);
    }

    /**
     * Human readable bytes
     * @param int $size
     * @param int $round
     * @return string
    */
    public static function dataSize($size, $round = 2)
    {
        $round = abs((int)$round);
        $mod = 1024;
        $units = explode(' ','B KB MB GB TB PB');
        for ($i = 0; (int)$size > $mod; $i++)
        {
            (int)$size /= $mod;
        }
        return round((int)$size, $round) . ' ' . $units[$i];
    }


    /**
     * Human readable xml array/object convertor
     * @param object|array $a
     * @return string
    */
    public static function ObjXml( $a )
    {
        $xml = NULL;
        foreach( $a as $k => $v )
        {

            $tag = trim( $k );
            $tagEnd = $tag = is_numeric( $tag ) ? 'num_'.$tag: $tag;

            $tagObj = explode( ' ', $tag );

            if( count( $tagObj ) > 1 )
            {
                $tagEnd = $tagObj[0];
            }

            $xml .= is_array( $v ) || is_object( $v ) ? "<$tag>".self::ObjXml( $v )."</$tagEnd>": "<$tag>".htmlentities( $v )."</$tagEnd>";
        }

        return $xml;
    }

    /**
    * Convert string to UTF-8
    * @param string $str
    * @return string
    */
    public static function autoUTF($str)
    {<commit_msg>Fomrat class updated<commit_after><?php
namespace Lethe;

/**
* Lethe\Format - data formatter
* @author <NAME> aka prochor <<EMAIL>>
* @version 1.2
*/
class Format
{
    /**
    * @ignore
    */
    final public function __construct(){}


    /**
     * Human readable bytes
     * @param int $size
     * @param int $round
     * @return string
    */
    public static function dataSize($size, $round = 2)
    {
        $round = abs((int)$round);
        $mod = 1024;
        $units = explode(' ','B KB MB GB TB PB');
        for ($i = 0; (int)$size > $mod; $i++)
        {
            (int)$size /= $mod;
        }
        return round($size, $round) . ' ' . $units[$i];
    }


    /**
     * Human readable xml array/object convertor
     * @param object|array $a
     * @return string
    */
    public static function ObjXml( $a )
    {
        $xml = NULL;
        foreach( $a as $k => $v )
        {
            $tag = trim( $k );
            $tagEnd = $tag = is_numeric( $tag ) ? 'num_'.$tag: $tag;

            $tagObj = explode( ' ', $tag );

            if( count( $tagObj ) > 1 )
            {
                $tagEnd = $tagObj[0];
            }

            $xml .= is_array( $v ) || is_object( $v ) ? "<$tag>".self::ObjXml( $v )."</$tagEnd>": "<$tag>".htmlentities( $v )."</$tagEnd>";
        }

        return $xml;
    }

    /**
    * Convert string to UTF-8
    * @param string $str
    * @return string
    */
    public static function autoUTF($str)
    {
{'fraction_non_alphanumeric': 0.16960813640442715, 'fraction_numerical': 0.006580915345498056, 'mean_word_length': 1.6476642913697546, 'pattern_counts': {'":': 2, '<': 19, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 8}, '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': '2600809', 'n_tokens_mistral': 1139, 'n_tokens_neox': 1095, 'n_words': 291}