<commit_before><?php

namespace core;

/**
 * This's a factory class for generating of View-objects (View, Layout).
 * @author coon
 */
class ViewFactory {

    /**
     * @ignore.
     */
    private function __construct() {
        // nothing here
    }

    /**
     * The method creates a view object assigned with the specific controller and 
     * action in it. If controller name is empty it means a markup file determined 
     * only with action name. It doesn't physically consist into the direcory named 
     * as controller, it's in the root of the view directory.
     * @param string $sCtrlName|null The controller name (as optional)
     * @param string $sActionName The action name.
     * @return \core\View|null It returns null if view file isn't readable.
     */
    public static function createView($sCtrlName = NULL, $sActionName) {
        $sViewsRoot = AppHelper::getInstance()->getComponentRoot('views');
        $sAddPath   = '';
        if (!empty($sCtrlName)) {
            $sAddPath .= DIRECTORY_SEPARATOR . strtolower($sCtrlName);
        }
        $sViewFile = $sViewsRoot
                . $sAddPath
                . DIRECTORY_SEPARATOR . strtolower($sActionName) . '.php';
        if (is_readable($sViewFile)) {
            return new View($sViewFile);
        }
        return NULL;
    }

    /**
     * It creates a layout object.
     * @param type $sLayoutName The layout name.
     * @param \core\View $oView The object of view.
     * @return \core\Layout|null
     */
    public static function createLayout($sLayoutName, View $oView) {
        $sLayoutsRoot = AppHelper::getInstance()->getComponentRoot('layouts');
        $sLayoutFile  = $sLayoutsRoot . DIRECTORY_SEPARATOR
                . strtolower($sLayoutName) . '.php';
        if (is_readable($sLayoutFile)) {
            return new Layout($sLayoutFile, $oView);
        }
        return NULL;
    }

    /**
     * The method creates a snippet-object.
     * @param type $sSnptName The snippet name.
     * @return \core\Snippet|null.
     */
    public static function createSnippet($sSnptName) {
        $sSnptRoot = AppHelper::getInstance()->getComponentRoot('snippets');
        $SnptFile  = $sSnptRoot . DIRECTORY_SEPARATOR
                . strtolower($sSnptName) . '.php';
        if (is_readable($SnptFile)) {
            return new Snippet($SnptFile);
        }
        return NULL;
    }

}<commit_msg>View factory class was formatted according PSR-2. Task #1 - The project codebase doesn't meet the PSR-2 standart.<commit_after><?php

namespace core;

/**
 * This's a factory class for generating of View-objects (View, Layout).
 * @author coon
 */
class ViewFactory
{

    /**
     * @ignore.
     */
    private function __construct()
    {
        // nothing here
    }

    /**
     * The method creates a view object assigned with the specific controller and 
     * action in it. If controller name is empty it means a markup file determined 
     * only with action name. It doesn't physically consist into the direcory named 
     * as controller, it's in the root of the view directory.
     * @param string $sCtrlName|null The controller name (as optional)
     * @param string $sActionName The action name.
     * @return \core\View|null It returns null if view file isn't readable.
     */
    public static function createView($sCtrlName = null, $sActionName)
    {
        $sViewsRoot = AppHelper::getInstance()->getComponentRoot('views');
        $sAddPath   = '';
        if (!empty($sCtrlName)) {
            $sAddPath .= DIRECTORY_SEPARATOR.strtolower($sCtrlName);
        }
        $sViewFile = $sViewsRoot.$sAddPath.DIRECTORY_SEPARATOR
            .strtolower($sActionName).'.php';
        if (is_readable($sViewFile)) {
            return new View($sViewFile);
        }
        return null;
    }

    /**
     * It creates a layout object.
     * @param type $sLayoutName The layout name.
     * @param \core\View $oView The object of view.
     * @return \core\Layout|null
     */
    public static function createLayout($sLayoutName, View $oView)
    {
        $sLayoutsRoot = AppHelper::getInstance()->getComponentRoot('layouts');
        $sLayoutFile  = $sLayoutsRoot.DIRECTORY_SEPARATOR
            .strtolower($sLayoutName).'.php';
        if (is_readable($sLayoutFile)) {
            return new Layout($sLayoutFile, $oView);
        }
        return null;
    }

    /**
     * The method creates a snippet-object.
     * @param type $sSnptName The snippet name.
     * @return \core\Snippet|null.
     */
    public static function createSnippet($sSnptName)
    {
        $sSnptRoot = AppHelper::getInstance()->getComponentRoot('snippets');
        $SnptFile  = $sSnptRoot.DIRECTORY_SEPARATOR
            .strtolower($sSnptName).'.php';
        if (is_readable($SnptFile)) {
            return new Snippet($SnptFile);
        }
        return null;
    }
}
{'fraction_non_alphanumeric': 0.11031810766721044, 'fraction_numerical': 0.0006117455138662316, 'mean_word_length': 2.348122866894198, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '1274949', 'n_tokens_mistral': 1446, 'n_tokens_neox': 1397, 'n_words': 396}