<commit_before><?php

/**
 * This file is part of CoverallsKit.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * This source file is subject to the MIT license that is bundled
 * with this source code in the file LICENSE.
 */

namespace coverallskit\report\parser;

use coverallskit\entity\SourceFile;
use coverallskit\entity\collection\SourceFileCollection;
use coverallskit\entity\Coverage;
use coverallskit\entity\collection\CoverageCollection;
use coverallskit\report\ReportParserInterface;
use coverallskit\exception\ExceptionCollection;

/**
 * Class LcovReportParser
 * @package coverallskit\report\parser
 */
class LcovReportParser implements ReportParserInterface
{

    /**
     * @var string
     */
    private $reportContent;

    /**
     * @param string $reportContent
     * @return Result
     */
    public function parse($reportContent)
    {
        $this->reportContent = $reportContent;
        $lines = explode(PHP_EOL, $this->reportContent);

        $sourceFile = null;
        $sourceCollection = new SourceFileCollection();
        $parseErrors = new ExceptionCollection();
        $coverages = [];

        foreach ($lines as $line) {
            if (preg_match('/SF:/', $line) === 1) {
                $name = preg_replace('/^SF:(.+)$/', '$1', $line);
                $sourceFile = new SourceFile($name);
                $coverages = [];
            } else if (preg_match('/end_of_record/', $line) === 1) {
                try {
                    $sourceFile->getCoverages()->addAll($coverages);
                } catch (ExceptionCollection $exception) {
                    $parseErrors->merge($exception);
                }
                $sourceCollection->add($sourceFile);
            } else if (preg_match('/DA:/', $line) === 1) {
                $line = preg_replace('/DA:/', '', $line);
                $params = explode(',', $line);
                list($lineNumber, $executeCount) = $params;

                $lineNumber = (int) $lineNumber;
                $analysisResult = ((int) $executeCount >= 1) ? Coverage::EXECUTED : Coverage::UNUSED;
<commit_msg>add currentSource<commit_after><?php

/**
 * This file is part of CoverallsKit.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * This source file is subject to the MIT license that is bundled
 * with this source code in the file LICENSE.
 */

namespace coverallskit\report\parser;

use coverallskit\entity\SourceFile;
use coverallskit\entity\collection\SourceFileCollection;
use coverallskit\entity\Coverage;
use coverallskit\entity\collection\CoverageCollection;
use coverallskit\report\ReportParserInterface;
use coverallskit\exception\ExceptionCollection;

/**
 * Class LcovReportParser
 * @package coverallskit\report\parser
 */
class LcovReportParser implements ReportParserInterface
{

    /**
     * @var string
     */
    private $reportContent;

    /**
     * @var SourceFile
     */
    private $currentSource;


    /**
     * @param string $reportContent
     * @return Result
     */
    public function parse($reportContent)
    {
        $this->reportContent = $reportContent;
        $lines = explode(PHP_EOL, $this->reportContent);

        $sourceFile = null;
        $sourceCollection = new SourceFileCollection();
        $parseErrors = new ExceptionCollection();
        $coverages = [];

        foreach ($lines as $line) {
            if (preg_match('/SF:/', $line) === 1) {
                $name = preg_replace('/^SF:(.+)$/', '$1', $line);
                $this->currentSource = new SourceFile($name);
                $coverages = [];
            } else if (preg_match('/end_of_record/', $line) === 1) {
                try {
                    $this->currentSource->getCoverages()->addAll($coverages);
                } catch (ExceptionCollection $exception) {
                    $parseErrors->merge($exception);
                }
                $sourceCollection->add($this->currentSource);
            } else if (preg_match('/DA:/', $line) === 1) {
                $line = preg_replace('/DA:/', '', $line);
                $params = explode(',', $line);
                list($lineNumber, $executeCount) = $params;

                $lineNumber = (int) $lineNumber;
                $analysisResult = ((int) $executeCount >= 1) ? Coverage::EXECUTED : Coverage::UNUSED;

{'fraction_non_alphanumeric': 0.13813320825515948, 'fraction_numerical': 0.0023452157598499064, 'mean_word_length': 2.368878357030016, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 26, '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': '6800728', 'n_tokens_mistral': 1229, 'n_tokens_neox': 1168, 'n_words': 263}