<commit_before><?php
/**
 * Pop PHP Framework (http://www.popphp.org/)
 *
 * @link       https://github.com/popphp/popphp-framework
 * @author     <NAME>, III <<EMAIL>>
 * @copyright  Copyright (c) 2009-2015 NOLA Interactive, LLC. (http://www.nolainteractive.com)
 * @license    http://www.popphp.org/license     New BSD License
 */

/**
 * @namespace
 */
namespace Pop\Data\Type;

/**
 * XML data type class
 *
 * @category   Pop
 * @package    Pop_Data
 * @author     <NAME>, III <<EMAIL>>
 * @copyright  Copyright (c) 2009-2015 NOLA Interactive, LLC. (http://www.nolainteractive.com)
 * @license    http://www.popphp.org/license     New BSD License
 * @version    2.0.0
 */
class Xml implements TypeInterface
{

    /**
     * Parse the string into a PHP array
     *
     * @param  string $string
     * @param  array  $options
     * @return array
     */
    public static function unserialize($string, array $options = [])
    {
        $matches = [];
        preg_match_all('/<!\[cdata\[(.*?)\]\]>/is', $string, $matches);

        foreach ($matches[0] as $match) {
            $strip = str_replace(
                ['<![CDATA[', ']]>', '<', '>'],
                ['', '', '&lt;', '&gt;'],
                $match
            );
            $string = str_replace($match, $strip, $string);
        }

        return json_decode(json_encode((array)simplexml_load_string($string)), true);
    }

    /**
     * Convert the data into its native string format
     *
     * @param  mixed $data
     * @param  array $options
     * @return string
     */
    public static function serialize($data, array $options = [])
    {
        $root     = (isset($options['root']))     ? $options['root']        : 'data';
        $node     = (isset($options['node']))     ? $options['node']        : 'row';
        $encoding = (isset($options['encoding'])) ? $options['encoding']    : 'utf-8';
        $cdata    = (isset($options['cdata']))    ? (bool)$options['cdata'] : false;
        $pma      = (isset($options['pma']))      ? (bool)$options['pma']   : false;
<commit_msg>Work on XML type class<commit_after><?php
/**
 * Pop PHP Framework (http://www.popphp.org/)
 *
 * @link       https://github.com/popphp/popphp-framework
 * @author     <NAME>, III <<EMAIL>>
 * @copyright  Copyright (c) 2009-2015 NOLA Interactive, LLC. (http://www.nolainteractive.com)
 * @license    http://www.popphp.org/license     New BSD License
 */

/**
 * @namespace
 */
namespace Pop\Data\Type;

/**
 * XML data type class
 *
 * @category   Pop
 * @package    Pop_Data
 * @author     <NAME>, III <<EMAIL>>
 * @copyright  Copyright (c) 2009-2015 NOLA Interactive, LLC. (http://www.nolainteractive.com)
 * @license    http://www.popphp.org/license     New BSD License
 * @version    2.0.0
 */
class Xml implements TypeInterface
{

    /**
     * Parse the string into a PHP array
     *
     * @param  string $string
     * @param  array  $options
     * @return mixed
     */
    public static function unserialize($string, array $options = [])
    {
        $matches = [];
        preg_match_all('/<!\[cdata\[(.*?)\]\]>/is', $string, $matches);

        foreach ($matches[0] as $match) {
            $strip = str_replace(
                ['<![CDATA[', ']]>', '<', '>'],
                ['', '', '&lt;', '&gt;'],
                $match
            );
            $string = str_replace($match, $strip, $string);
        }

        $xml = (isset($options['options'])) ?
            simplexml_load_string($string, $options['options']) : simplexml_load_string($string);

        if ((isset($options['xml']) && !($options['xml'])) || !isset($options['xml'])) {
            $xml = json_decode(json_encode((array)$xml), true);
        }

        return $xml;
    }

    /**
     * Convert the data into its native string format
     *
     * @param  mixed $data
     * @param  array $options
     * @return string
     */
    public static function serialize($data, array $options = [])
    {
        $root     = (isset($options['root']))     ? $options['root']        : 'data';
        $node     = (isset($options['node']))     ? $options['node']        : 'row';
        $encoding = (isset($options['encoding'])) ? $options['encoding']    : 'utf-8';
        $cdata    = (isset($options['cdata']))    ? (bool)$options['cdata'] : false;
        $pma      = (isset($options['pma']))      ? (bool)$options['pma']   : false;

{'fraction_non_alphanumeric': 0.187143834055163, 'fraction_numerical': 0.009573740597219056, 'mean_word_length': 2.255192878338279, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 21, 'https://': 2, 'lorem ipsum': 0, 'www.': 10, 'xml': 10}, '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': '7414151', 'n_tokens_mistral': 1406, 'n_tokens_neox': 1357, 'n_words': 299}