<commit_before><?php
/**
 * This file is part of the Cecil/Cecil package.
 *
 * Copyright (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Cecil\Converter;

use Cecil\Builder;
use Cecil\Exception\Exception;
use Symfony\Component\Yaml\Exception\ParseException;
use Symfony\Component\Yaml\Yaml;

/**
 * Class Converter.
 */
class Converter implements ConverterInterface
{
    /** @var Builder */
    protected $builder;

    public function __construct(Builder $builder)
    {
        $this->builder = $builder;
    }

    /**
     * {@inheritdoc}
     */
    public function convertFrontmatter(string $string, string $type = 'yaml'): array
    {
        switch ($type) {
            case 'ini':
                $result = parse_ini_string($string);
                if ($result === false) {
                    throw new Exception('Can\'t parse INI front matter');
                }

                return $result;
            case 'yaml':
            default:
                try {
                    $string = addcslashes($string, '\\');
                    $result = Yaml::parse((string) $string);
                    if (!is_array($result)) {
                        throw new Exception('Parse result of YAML front matter is not an array');
                    }

                    return $result;
                } catch (ParseException $e) {
                    throw new Exception($e->getMessage());
                }
        }
    }

    /**
     * {@inheritdoc}
     */
    public function convertBody(string $string): string<commit_msg>fix: remove addcslashes<commit_after><?php
/**
 * This file is part of the Cecil/Cecil package.
 *
 * Copyright (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Cecil\Converter;

use Cecil\Builder;
use Cecil\Exception\Exception;
use Symfony\Component\Yaml\Exception\ParseException;
use Symfony\Component\Yaml\Yaml;

/**
 * Class Converter.
 */
class Converter implements ConverterInterface
{
    /** @var Builder */
    protected $builder;

    public function __construct(Builder $builder)
    {
        $this->builder = $builder;
    }

    /**
     * {@inheritdoc}
     */
    public function convertFrontmatter(string $string, string $type = 'yaml'): array
    {
        switch ($type) {
            case 'ini':
                $result = parse_ini_string($string);
                if ($result === false) {
                    throw new Exception('Can\'t parse INI front matter');
                }

                return $result;
            case 'yaml':
            default:
                try {
                    $result = Yaml::parse((string) $string);
                    if (!is_array($result)) {
                        throw new Exception('Parse result of YAML front matter is not an array');
                    }

                    return $result;
                } catch (ParseException $e) {
                    throw new Exception($e->getMessage());
                }
        }
    }

    /**
     * {@inheritdoc}
     */
    public function convertBody(string $string): string
{'fraction_non_alphanumeric': 0.11280487804878049, 'fraction_numerical': 0.0, 'mean_word_length': 1.7456066945606694, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 13, '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': '3715663', 'n_tokens_mistral': 869, 'n_tokens_neox': 821, 'n_words': 243}