<commit_before><?php
/**
 * DronePHP (http://www.dronephp.com)
 *
 * @link      http://github.com/Pleets/DronePHP
 * @copyright Copyright (c) 2016-2018 Pleets. (http://www.pleets.org)
 * @license   http://www.dronephp.com/license
 * @author    <NAME> <<EMAIL>>
 */

namespace Drone\Mvc;

/**
 * View class
 *
 * This class manages views and parameters
 */
class View
{
    use \Drone\Util\ParamTrait;

    /**
     * View name
     *
     * @var string
     */
    protected $name;

    /**
     * The path where views are located.
     *
     * @var string
     */
    protected $path;

    /**
     * Returns the view name
     *
     * @return string
     */
    public function getName()
    {
        return $this->name;
    }

    /**
     * Returns the path
     *
     * @return string
     */
    public function getPath()
    {
        return $this->path;
    }

    /**
     * Sets the view name
     *
     * @param string
     *
     * @return null
     */
    public function setName($name)
    {
        $this->name = $name;
    }

    /**
     * Sets the path
     *
     * @param string
     *
     * @return string
     */
    public function setPath($path)
    {
        $this->path = $path;
    }

    /**
     * Constructor
     *
     * @param string $name
     * @param array  $parameters
     */
    public function __construct($name, Array $parameters = [])
    {
        $this->name  = $name;
        $this->setParams($parameters);
    }

    /**
     * Get the contents of the view
     *
     * @throws Exception\ViewNotFoundException
     *
     * @return  null
     */
    public function getContents()
    {
        $contents = file_get_contents($_view);

        if ($contents === false) {
            throw new Exception\ViewGetContentsErrorException("The view '" .$this->name. "' does not exists");
        }

        return $contents;
    }

    /**
     * Loads the view
     *
     * @return  null
     */
    public function render()
    {
        if (count($this->getParams())) {
            extract($this->getParams(), EXTR_SKIP);
        }

        include $this->getFile();
    }

    /**
     * Gets the file path
     *
     * @return  string
     */
    private function getFile()
    {
        $_view = $this->path . DIRECTORY_SEPARATOR . $this->name . '.phtml';

        if (!file_exists($_view)) {
            throw new Exception\ViewNotFoundException("The view '" .$this->name. "' does not exists");
        }<commit_msg>Add path conversion on View<commit_after><?php
/**
 * DronePHP (http://www.dronephp.com)
 *
 * @link      http://github.com/Pleets/DronePHP
 * @copyright Copyright (c) 2016-2018 Pleets. (http://www.pleets.org)
 * @license   http://www.dronephp.com/license
 * @author    <NAME> <<EMAIL>>
 */

namespace Drone\Mvc;

/**
 * View class
 *
 * This class manages views and parameters
 */
class View
{
    use \Drone\Util\ParamTrait;

    /**
     * View name
     *
     * @var string
     */
    protected $name;

    /**
     * The path where views are located.
     *
     * @var string
     */
    protected $path;

    /**
     * Returns the view name
     *
     * @return string
     */
    public function getName()
    {
        return $this->name;
    }

    /**
     * Returns the path
     *
     * @return string
     */
    public function getPath()
    {
        return $this->path;
    }

    /**
     * Sets the view name
     *
     * @param string
     *
     * @return null
     */
    public function setName($name)
    {
        $this->name = $name;
    }

    /**
     * Sets the path
     *
     * @param string
     *
     * @return string
     */
    public function setPath($path)
    {
        $this->path = $path;
    }

    /**
     * Constructor
     *
     * @param string $name
     * @param array  $parameters
     */
    public function __construct($name, Array $parameters = [])
    {
        $this->name  = $name;
        $this->setParams($parameters);
    }

    /**
     * Get the contents of the view
     *
     * @throws Exception\ViewNotFoundException
     *
     * @return  null
     */
    public function getContents()
    {
        $contents = file_get_contents($_view);

        if ($contents === false) {
            throw new Exception\ViewGetContentsErrorException("The view '" .$this->name. "' does not exists");
        }

        return $contents;
    }

    /**
     * Loads the view
     *
     * @return  null
     */
    public function render()
    {
        if (count($this->getParams())) {
            extract($this->getParams(), EXTR_SKIP);
        }

        include $this->getFile();
    }

    /**
     * Gets the file path
     *
     * @return  string
     */
    private function getFile()
    {
        $_view = $this->path . DIRECTORY_SEPARATOR .
            str_replace('.', DIRECTORY_SEPARATOR, $this->name) . '.phtml';

        if (!file_exists($_view)) {
            throw new Exception\ViewNotFoundException("The view '" .$this->name. "' does not exists");
        }
{'fraction_non_alphanumeric': 0.14005994005994005, 'fraction_numerical': 0.003196803196803197, 'mean_word_length': 1.6430834213305174, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 6, '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': '61835', 'n_tokens_mistral': 1569, 'n_tokens_neox': 1524, 'n_words': 352}