<commit_before><?php

namespace App\ViewModelFilter\Filter;

use App\ViewModelFilter\ViewModelFilterInterface;
use Core\ControllerDispatcher\RequestMatcher;
use Core\ViewModel;
use Parsedown;

class MarkdownFilter implements ViewModelFilterInterface
{
    public function filter(ViewModel $viewModel)
    {
        foreach ($viewModel->getVariables() as $key => $value) {
            if($this->isContent($key)) {
                $value->setContent($this->markdown($value->getContent()));
            }
        }
    }

    private function isContent($key) {
        if(strpos(RequestMatcher::getControllerProc()->getName(), 'showEditForm') !== false) {
            return false;
        }

        return $key === 'post' || $key === 'comment';
    }

    private function markdown($str) {
        $parsedown = new Parsedown();
        $parsedown->setMarkupEscaped(true);

        return $parsedown->text($str);
    }
}<commit_msg>Fixed PSR-2 coding style<commit_after><?php

namespace App\ViewModelFilter\Filter;

use App\ViewModelFilter\ViewModelFilterInterface;
use Core\ControllerDispatcher\RequestMatcher;
use Core\ViewModel;
use Parsedown;

class MarkdownFilter implements ViewModelFilterInterface
{
    public function filter(ViewModel $viewModel)
    {
        foreach ($viewModel->getVariables() as $key => $value) {
            if($this->isContent($key)) {
                $value->setContent($this->markdown($value->getContent()));
            }
        }
    }

    private function isContent($key)
    {
        if(strpos(RequestMatcher::getControllerProc()->getName(), 'showEditForm') !== false) {
            return false;
        }

        return $key === 'post' || $key === 'comment';
    }

    private function markdown($str)
    {
        $parsedown = new Parsedown();
        $parsedown->setMarkupEscaped(true);

        return $parsedown->text($str);
    }
}
{'fraction_non_alphanumeric': 0.13571048430015967, 'fraction_numerical': 0.0005321979776476849, 'mean_word_length': 2.9248434237995826, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 21, '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': '6710516', 'n_tokens_mistral': 535, 'n_tokens_neox': 515, 'n_words': 99}