<commit_before><?php
/**
 * WebHemi.
 *
 * PHP version 7.1
 *
 * @copyright 2012 - 2017 Gixx-web (http://www.gixx-web.com)
 * @license   https://opensource.org/licenses/MIT The MIT License (MIT)
 *
 * @link      http://www.gixx-web.com
 */
declare(strict_types = 1);

namespace WebHemi\Adapter\Renderer\Twig;

use Twig_Extension;
use Twig_SimpleFunction;

/**
 * Class WebHemiTwigExtension
 */
class WebHemiTwigExtension extends Twig_Extension
{
    /** @var string */
    private $viewPath;

    /**
     * WebHemiTwigExtension constructor.
     *
     * @param string $viewPath
     */
    public function __construct(string $viewPath)
    {
        $this->viewPath = $viewPath;
    }

    /**
     * Returns extension functions.
     *
     * @return array<Twig_SimpleFunction)
     */
    public function getFunctions() : array
    {
        return [
            new Twig_SimpleFunction('defined', array($this, 'isDefined')),
            new Twig_SimpleFunction('getStat', array($this, 'getStat')),
        ];
    }

    /**
     * Checks if a file exists on the view path.
     *
     * @param string $fileName
     * @return bool
     */
    public function isDefined(string $fileName) : bool
    {
        $fileName = str_replace('@Theme', $this->viewPath, $fileName);
        return file_exists($fileName);
    }

    /**
     * Returns render statistics.
     *
     * @return array
     */
    public function getStat() : array
    {<commit_msg>Fix PHPDoc<commit_after><?php
/**
 * WebHemi.
 *
 * PHP version 7.1
 *
 * @copyright 2012 - 2017 Gixx-web (http://www.gixx-web.com)
 * @license   https://opensource.org/licenses/MIT The MIT License (MIT)
 *
 * @link      http://www.gixx-web.com
 */
declare(strict_types = 1);

namespace WebHemi\Adapter\Renderer\Twig;

use Twig_Extension;
use Twig_SimpleFunction;

/**
 * Class WebHemiTwigExtension
 */
class WebHemiTwigExtension extends Twig_Extension
{
    /** @var string */
    private $viewPath;

    /**
     * WebHemiTwigExtension constructor.
     *
     * @param string $viewPath
     */
    public function __construct(string $viewPath)
    {
        $this->viewPath = $viewPath;
    }

    /**
     * Returns extension functions.
     *
     * @return array<Twig_SimpleFunction>
     */
    public function getFunctions() : array
    {
        return [
            new Twig_SimpleFunction('defined', array($this, 'isDefined')),
            new Twig_SimpleFunction('getStat', array($this, 'getStat')),
        ];
    }

    /**
     * Checks if a file exists on the view path.
     *
     * @param string $fileName
     * @return bool
     */
    public function isDefined(string $fileName) : bool
    {
        $fileName = str_replace('@Theme', $this->viewPath, $fileName);
        return file_exists($fileName);
    }

    /**
     * Returns render statistics.
     *
     * @return array
     */
    public function getStat() : array
    {
{'fraction_non_alphanumeric': 0.13003095975232198, 'fraction_numerical': 0.007567939456484348, 'mean_word_length': 2.334862385321101, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 8, 'https://': 2, 'lorem ipsum': 0, 'www.': 4, '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': '5710077', 'n_tokens_mistral': 932, 'n_tokens_neox': 913, 'n_words': 199}