<commit_before><?php
/**
 *
 */

namespace Mvc5\View\Model;

use Mvc5\Config\Base as ConfigBase;

trait Base
{
    /**
     *
     */
    use ConfigBase;

    /**
     * @param $template
     * @param array $config
     */
    public function __construct($template = null, array $config = [])
    {
        $config   && $this->config = $config;
        $template && $this->template($template);
    }

    /**
     * @param string|ViewModel $model
     * @return void
     */
    public function child($model)
    {
        $this->set(ViewModel::CHILD, $model);
    }

    /**
     * @return array
     */
    public function assigned()
    {
        return $this->config;
    }

    /**
     * @return string|self
     */
    public function model()
    {
        return $this->get(ViewModel::CHILD);
    }

    /**
     * @return string
     */
    public function path()
    {
        return $this->get(ViewModel::TEMPLATE);
    }

    /**
     * @param string $template
     * @return void
     */
    public function template($template)
    {
        $this->set(ViewModel::TEMPLATE, $template);
    }

    /**
     * @param array $config
     * @return void
     */
    public function vars(array $config = [])
    {
        $this->config = $config + $this->config + [
                ViewModel::TEMPLATE => $this->path(),
                ViewModel::CHILD    => $this->model()
            ];
    }

    /**
     * @param $name
     * @return mixed
     */
    public function __get($name)
    {
        return $this->get($name);
    }

    /**
     * @param $name
     * @return bool
     */
    public function __isset($name)
    {
        return $this->has($name);
    }

    /**
     * @param $name
     * @param $value
     * @return mixed
     */
    public function __set($name, $value)
    {
        $this->set($name, $value);
    }

    /**
     * @param $name
     * @return mixed
     */
    public function __unset($name)
    {
        $this->remove($name);
    }
}
<commit_msg>Add const TEMPLATE_NAME for ViewModel autowiring<commit_after><?php
/**
 *
 */

namespace Mvc5\View\Model;

use Mvc5\Config\Base as ConfigBase;

trait Base
{
    /**
     *
     */
    use ConfigBase;

    /**
     * @param $template
     * @param array $config
     */
    public function __construct($template = null, array $config = [])
    {
        $this->config = $config + [
            ViewModel::TEMPLATE => $template
                ?: (defined('static::TEMPLATE_NAME') ? constant('static::TEMPLATE_NAME') : null)
        ];
    }

    /**
     * @param string|ViewModel $model
     * @return void
     */
    public function child($model)
    {
        $this->set(ViewModel::CHILD, $model);
    }

    /**
     * @return array
     */
    public function assigned()
    {
        return $this->config;
    }

    /**
     * @return string|self
     */
    public function model()
    {
        return $this->get(ViewModel::CHILD);
    }

    /**
     * @return string
     */
    public function path()
    {
        return $this->get(ViewModel::TEMPLATE);
    }

    /**
     * @param string $template
     * @return void
     */
    public function template($template)
    {
        $this->set(ViewModel::TEMPLATE, $template);
    }

    /**
     * @param array $config
     * @return void
     */
    public function vars(array $config = [])
    {
        $this->config = $config + $this->config + [
                ViewModel::TEMPLATE => $this->path(),
                ViewModel::CHILD    => $this->model()
            ];
    }

    /**
     * @param $name
     * @return mixed
     */
    public function __get($name)
    {
        return $this->get($name);
    }

    /**
     * @param $name
     * @return bool
     */
    public function __isset($name)
    {
        return $this->has($name);
    }

    /**
     * @param $name
     * @param $value
     * @return mixed
     */
    public function __set($name, $value)
    {
        $this->set($name, $value);
    }

    /**
     * @param $name
     * @return mixed
     */
    public function __unset($name)
    {
        $this->remove($name);
    }
}

{'fraction_non_alphanumeric': 0.1572296476306197, 'fraction_numerical': 0.0009720534629404617, 'mean_word_length': 1.628352490421456, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 37, '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': '2814901', 'n_tokens_mistral': 1313, 'n_tokens_neox': 1272, 'n_words': 251}