<commit_before><?php

namespace Browscap\Parser;

class IniParser implements ParserInterface
{

    /**
     * @var string
     */
    protected $filename;

    /**
     * @var bool
     */
    protected $shouldSort = false;

    /**
     * @var array
     */
    protected $data;

    protected $fileLines;

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

    /**
     * @param bool $shouldSort
     * @return \Browscap\Parser\IniParser
     */
    public function setShouldSort($shouldSort)
    {
        $this->shouldSort = (bool)$shouldSort;
        return $this;
    }

    public function shouldSort()
    {
        return $this->shouldSort;
    }

    public function getParsed()
    {
        return $this->data;
    }

    public function getFilename()
    {
        return $this->filename;
    }

    public function getLinesFromFile()
    {
        $filename = $this->filename;

        if (!file_exists($filename)) {
            throw new \Exception("File not found: {$filename}");
        }

        return file($filename, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
    }

    public function setFileLines(array $fileLines)
    {
        $this->fileLines = $fileLines;
    }

    public function parse()
    {
        if (!$this->fileLines) {
            $fileLines = $this->getLinesFromFile();
        } else {
            $fileLines = $this->fileLines;
        }

        $data = array();

        $currentSection = '';
        $currentDivision = '';

        for ($line = 0; $line < count($fileLines); $line++) {

            $currentLine = ($fileLines[$line]);
            $currentLineLength = strlen($currentLine);

            if ($currentLineLength == 0) {
                continue;
            }

            if (substr($currentLine, 0, 40) == ';;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;') {
                $currentDivision = trim(substr($currentLine, 41));
                continue;<commit_msg>Created new getFileLines method<commit_after><?php

namespace Browscap\Parser;

class IniParser implements ParserInterface
{

    /**
     * @var string
     */
    protected $filename;

    /**
     * @var bool
     */
    protected $shouldSort = false;

    /**
     * @var array
     */
    protected $data;

    protected $fileLines;

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

    /**
     * @param bool $shouldSort
     * @return \Browscap\Parser\IniParser
     */
    public function setShouldSort($shouldSort)
    {
        $this->shouldSort = (bool)$shouldSort;
        return $this;
    }

    public function shouldSort()
    {
        return $this->shouldSort;
    }

    public function getParsed()
    {
        return $this->data;
    }

    public function getFilename()
    {
        return $this->filename;
    }

    public function getLinesFromFile()
    {
        $filename = $this->filename;

        if (!file_exists($filename)) {
            throw new \Exception("File not found: {$filename}");
        }

        return file($filename, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
    }

    public function setFileLines(array $fileLines)
    {
        $this->fileLines = $fileLines;
    }

    public function getFileLines()
    {
        if (!$this->fileLines) {
            $fileLines = $this->getLinesFromFile();
        } else {
            $fileLines = $this->fileLines;
        }

        return $fileLines;
    }

    public function parse()
    {
        $fileLines = $this->getFileLines();

        $data = array();

        $currentSection = '';
        $currentDivision = '';

        for ($line = 0; $line < count($fileLines); $line++) {

            $currentLine = ($fileLines[$line]);
            $currentLineLength = strlen($currentLine);

            if ($currentLineLength == 0) {
                continue;
            }

            if (substr($currentLine, 0, 40) == ';;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;') {
                $currentDivision = trim(substr($currentLine, 41));
                continue;
{'fraction_non_alphanumeric': 0.14503441494591937, 'fraction_numerical': 0.00344149459193707, 'mean_word_length': 1.9210337401292175, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 24, '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': '5608716', 'n_tokens_mistral': 1220, 'n_tokens_neox': 1140, 'n_words': 235}