<commit_before><?php declare(strict_types=1);

namespace Symplify\ChangelogLinker;

use Symplify\ChangelogLinker\Contract\Worker\WorkerInterface;

final class ChangelogApplication
{
    /**
     * @var WorkerInterface[]
     */
    private $workers = [];

    /**
     * @todo with some order?
     */
    public function addWorker(WorkerInterface $worker): void
    {
        $this->workers[] = $worker;
    }

    public function processFileAndSave(string $filePath): void
    {
        $content = $this->processFile($filePath);
        file_put_contents($filePath, $content);
    }

    public function processFile(string $filePath): string
    {
        $content = file_get_contents($filePath);

        foreach ($this->workers as $worker) {
            $content = $worker->processContent($content);
        }

        return $content;
    }

    public function processFileWithSingleWorker(string $filePath, string $workerClass): string
    {
        $content = file_get_contents($filePath);

        foreach ($this->workers as $worker) {
            if (! $worker instanceof $workerClass) {
                continue;
            }

            return $worker->processContent($content);
        }

        return $content;
    }
}<commit_msg>simplify method loop<commit_after><?php declare(strict_types=1);

namespace Symplify\ChangelogLinker;

use Symplify\ChangelogLinker\Contract\Worker\WorkerInterface;

final class ChangelogApplication
{
    /**
     * @var WorkerInterface[]
     */
    private $workers = [];

    /**
     * @todo with some order?
     */
    public function addWorker(WorkerInterface $worker): void
    {
        $this->workers[] = $worker;
    }

    public function processFileAndSave(string $filePath): void
    {
        $content = $this->processFile($filePath);
        file_put_contents($filePath, $content);
    }

    public function processFile(string $filePath): string
    {
        $content = file_get_contents($filePath);

        foreach ($this->workers as $worker) {
            $content = $worker->processContent($content);
        }

        return $content;
    }

    public function processFileWithSingleWorker(string $filePath, string $workerClass): string
    {
        $content = file_get_contents($filePath);

        foreach ($this->workers as $worker) {
            if ($worker instanceof $workerClass) {
                return $worker->processContent($content);
            }
        }

        return $content;
    }
}
{'fraction_non_alphanumeric': 0.11631663974151858, 'fraction_numerical': 0.0008077544426494346, 'mean_word_length': 2.518465909090909, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 15, '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': '1558617', 'n_tokens_mistral': 695, 'n_tokens_neox': 671, 'n_words': 141}