<commit_before><?php
namespace Avenue;

use Avenue\App;
use Avenue\Helpers\HelperBundleTrait;
use Avenue\Interfaces\ViewInterface;

class View implements ViewInterface
{
    use HelperBundleTrait;

    /**
     * Avenue class instance.
     *
     * @var \Avenue\App
     */
    protected $app;

    /**
     * List of view helpers.
     *
     * @var array
     */
    protected $helpers = [];

    /**
     * Parameters for magic methods.
     *
     * @var array
     */
    protected $params = [];

    /**
     * Layouts directory.
     *
     * @var string
     */
    const LAYOUT_DIR = 'layouts';

    /**
     * Partials directory.
     *
     * @var string
     */
    const PARTIAL_DIR = 'partials';

    /**
     * View class constructor.
     *
     * @param App $app
     */
    public function __construct(App $app)
    {
        $this->app = $app;
    }

    /**
     * Fetching the view file and getting the contents.
     *
     * @param mixed $filename
     * @param array $params
     * @return string
     */
    public function fetch($filename, array $params = [])
    {
        ob_start();

        // store file name to temp variable and later usage
        $target = $filename; unset($filename);

        // merge with direct variables assignment to object
        // the latter will overwrite the first
        extract(array_merge($this->params, $params));
        require $this->getViewFile($target);

        return ob_get_clean();
    }

    /**
     * Alias method. Fetching layout view file by omitting directory name.
     *
     * @param  mixed $filename
     * @param  array $params
     * @return mixed<commit_msg>fixed filename get overwriten with same param name.<commit_after><?php
namespace Avenue;

use Avenue\App;
use Avenue\Helpers\HelperBundleTrait;
use Avenue\Interfaces\ViewInterface;

class View implements ViewInterface
{
    use HelperBundleTrait;

    /**
     * Avenue class instance.
     *
     * @var \Avenue\App
     */
    protected $app;

    /**
     * List of view helpers.
     *
     * @var array
     */
    protected $helpers = [];

    /**
     * Parameters for magic methods.
     *
     * @var array
     */
    protected $params = [];

    /**
     * The target view file.
     *
     * @var mixed
     */
    protected $target;

    /**
     * Layouts directory.
     *
     * @var string
     */
    const LAYOUT_DIR = 'layouts';

    /**
     * Partials directory.
     *
     * @var string
     */
    const PARTIAL_DIR = 'partials';

    /**
     * View class constructor.
     *
     * @param App $app
     */
    public function __construct(App $app)
    {
        $this->app = $app;
    }

    /**
     * Fetching the view file and getting the contents.
     *
     * @param mixed $filename
     * @param array $params
     * @return string
     */
    public function fetch($filename, array $params = [])
    {
        ob_start();

        // store file name to temp variable and later usage
        $this->target = $filename; unset($filename);

        // merge with direct variables assignment to object
        // the latter will overwrite the first
        extract(array_merge($this->params, $params));
        require $this->getViewFile($this->target);

        return ob_get_clean();
    }

    /**
     * Alias method. Fetching layout view file by omitting directory name.
     *
     * @param  mixed $filename
     * @param  array $params
     * @return mixed
{'fraction_non_alphanumeric': 0.11417780360255665, 'fraction_numerical': 0.0, 'mean_word_length': 1.8454545454545455, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, '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': '2167433', 'n_tokens_mistral': 1012, 'n_tokens_neox': 992, 'n_words': 284}