<commit_before><?php

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

namespace Supervisor\Configuration\Parser;

use Supervisor\Configuration;
use Supervisor\Exception\ParsingFailed;

/**
 * Parse configuration from string
 *
 * @author <NAME> <<EMAIL>>
 */
class Text extends Base
{
    /**
     * @var string
     */
    protected $text;

    /**
     * @param string $text
     */
    public function __construct($text)
    {
        $this->text = $text;
    }

    /**
     * {@inheritdoc}
     */
    public function parse(Configuration $configuration = null)
    {
        if (is_null($configuration)) {
            $configuration = new Configuration;
        }

        // Suppress error to handle it
        if (!$ini = @parse_ini_string($this->text, true, INI_SCANNER_RAW)) {
            throw new ParsingFailed('Given data cannot be parsed as INI string');
        }

        $sections = $this->parseArray($ini);
        $configuration->addSections($sections);

        return $configuration;
    }
}<commit_msg>- fixed parsing empty ini text: the empty array result of parse_ini_string was evaluated to false. added ===<commit_after><?php

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

namespace Supervisor\Configuration\Parser;

use Supervisor\Configuration;
use Supervisor\Exception\ParsingFailed;

/**
 * Parse configuration from string
 *
 * @author <NAME> <<EMAIL>>
 */
class Text extends Base
{
    /**
     * @var string
     */
    protected $text;

    /**
     * @param string $text
     */
    public function __construct($text)
    {
        $this->text = $text;
    }

    /**
     * {@inheritdoc}
     */
    public function parse(Configuration $configuration = null)
    {
        if (is_null($configuration)) {
            $configuration = new Configuration;
        }

        // Suppress error to handle it
        if (false === $ini = @parse_ini_string($this->text, true, INI_SCANNER_RAW)) {
            throw new ParsingFailed('Given data cannot be parsed as INI string');
        }

        $sections = $this->parseArray($ini);
        $configuration->addSections($sections);

        return $configuration;
    }
}
{'fraction_non_alphanumeric': 0.11802232854864433, 'fraction_numerical': 0.0, 'mean_word_length': 2.5437853107344632, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 23, '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': '4718818', 'n_tokens_mistral': 699, 'n_tokens_neox': 685, 'n_words': 214}