<commit_before><?php
namespace RocketTheme\Toolbox\ArrayTraits;

use Symfony\Component\Yaml\Yaml;

/**
 * Implements ExportInterface.
 *
 * @package RocketTheme\Toolbox\ArrayTraits
 * @author RocketTheme
 * @license MIT
 *
 * @property array $items
 */
trait Export
{
    /**
     * Convert object into an array.
     *
     * @return array
     */
    public function toArray()
    {
        return $this->items;
    }

    /**
     * Convert object into YAML string.
     *
     * @return string
     */
    public function toYaml()
    {
        return Yaml::dump($this->toArray());
    }

    /**
     * Convert object into JSON string.
     *
     * @return string
     */
    public function toJson()
    {
        return json_encode($this->toArray());
    }
}<commit_msg>ArrayTraits\Export: throw DumpException if object cannot be represented in YAML<commit_after><?php
namespace RocketTheme\Toolbox\ArrayTraits;

use Symfony\Component\Yaml\Exception\DumpException;
use Symfony\Component\Yaml\Yaml;

/**
 * Implements ExportInterface.
 *
 * @package RocketTheme\Toolbox\ArrayTraits
 * @author RocketTheme
 * @license MIT
 *
 * @property array $items
 */
trait Export
{
    /**
     * Convert object into an array.
     *
     * @return array
     */
    public function toArray()
    {
        return $this->items;
    }

    /**
     * Convert object into YAML string.
     *
     * @param  int $inline  The level where you switch to inline YAML.
     * @param  int $indent  The amount of spaces to use for indentation of nested nodes.
     *
     * @return string A YAML string representing the object.
     * @throws DumpException
     */
    public function toYaml($inline = 2, $indent = 4)
    {
        return Yaml::dump($this->toArray(), $inline, $indent, true, false);
    }

    /**
     * Convert object into JSON string.
     *
     * @return string
     */
    public function toJson()
    {
        return json_encode($this->toArray());
    }
}
{'fraction_non_alphanumeric': 0.11507128309572301, 'fraction_numerical': 0.0010183299389002036, 'mean_word_length': 2.3192567567567566, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '209284', 'n_tokens_mistral': 606, 'n_tokens_neox': 593, 'n_words': 160}