<commit_before><?php

/**
 * @author <NAME> <<EMAIL>>
 * @version 1.0
 * @package SideNav
 * @since 19 Sep 2016
 * SideNav main class
 */

namespace Anetwork\SideNav;

class SideNav
{

    // use Sidenav helper methods in class
    use SideNavHelpers;

    // group route
    protected static $group;

    // current position of route
    protected static $currentRoute;

    // the item url
    protected static $url;

    // all routes-name registered
    protected static $routes = [];

    // instance of check status object
    protected static $checkStatusObject = [];

    // status of navigation
    protected static $status = false;

    // render array
    protected static $menu = [];

    /**
     * Define checkstatus object
     *
     * @author <NAME> <<EMAIL>>
     * @since  19 Sep 2016
     * @param  $class
     */
    public static function checkStatusObject($class,$method)
    {
        self::$checkStatusObject = [
            'object' => $class,
            'method' => $method
        ];
    }

    /**
     * Make the SideNav group
     *
     * @author <NAME> <<EMAIL>>
     * @since  19 Sep 2016
     * @param  $group
     * @param  $callback
     */
    public static function group($group, $callback)
    {
        // set group menu name
        self::$group = $group;

        // set group menu
        self::$menu[$group] = [];

        // run callback function
        $callback();
    }

    /**
     * Register a new menu item
     *
     * @author <NAME> <<EMAIL>>
     * @since  19 Sep 2016
     * @param  $route
     * @param  $callback
     */
    public static function register($route, $callback)
    {
        // set current route
        self::$currentRoute = $route;

        // register route
        self::$routes[self::$currentRoute] = [];

        // make menu array
        $array = self::add($route, $callback);

        if (self::checkGroupId(self::$group)) {
            // add to the group render array
            array_push(self::$menu[self::$group], $array);
        }

        // add to the single render array
        array_push(self::$menu, $array);
    }

    /**
     * Register a new menu item
     *
     * @author <NAME> <<EMAIL>>
     * @since  19 Sep 2016
     * @param  $route
     * @param  $callback
     * @param  $checkCallback
     */
    public static function registerWithCheck($route , $callback , $checkCallback = null)
    {
        // check status of route
        if (self::checkStatus($route, $checkCallback)) {
            self::register($route, $callback);
        }
    }

    /**
     * Add the submenu to item
     *
     * @author <NAME> <<EMAIL>>
     * @since  19 Sep 2016
     * @param  $route
     * @param  $callback
     * @return array
     */
    public static function addSub($route, $callback)
    {
        // register route name
        array_push(self::$routes[self::$currentRoute], $route);

        // return submenu array
        return self::add($route, $callback);
    }

    /**
     * Add the menu item
     *
     * @author <NAME> <<EMAIL>>
     * @since  19 Sep 2016
     * @param  $route
     * @param  $callback
     * @return array
     */
    private static function add($route,$callback)
    {
        // instance of menu class
        $menu = new Menu;

        // run callback function
        $callback($menu);

        // Make the menu object array
        return $menu->make($route);
    }

    /**
     * Get all routes
     *
     * @author <NAME> <<EMAIL>>
     * @since  19 Sep 2016
     * @return array
     */
    public static function routes($index = null)
    {
        if($index !== null) {
            return self::$routes[$index];
        }

        // return array of all routes-name
        return self::$routes;
    }


    /**
     * Render the menu items
     *
     * @author <NAME> <<EMAIL>>
     * @since  19 Sep 2016
     * @return mixed
     */
    public static function render($type = null)
    {
        // return single menu array
        return self::$menu;
    }

    /**
     * Check group id
     *<commit_msg>Optimize SideNav object and solved the typo mistake<commit_after><?php

/**
 * @author <NAME> <<EMAIL>>
 * @version 1.0
 * @package SideNav
 * @since 19 Sep 2016
 * SideNav main class
 */

namespace Anetwork\SideNav;

class SideNav
{

    // use Sidenav helper methods in class
    use SideNavHelpers;

    // group route
    protected static $group;

    // current position of route
    protected static $currentRoute;

    // the item url
    protected static $url;

    // all routes-name registered
    protected static $routes = [];

    // instance of check status object
    protected static $checkStatusObject = [];

    // status of navigation
    protected static $status = false;

    // render array
    protected static $menu = [];

    /**
     * Define checkstatus object
     *
     * @author <NAME> <<EMAIL>>
     * @since  19 Sep 2016
     * @param  $class
     */
    public static function checkStatusObject($class,$method)
    {
        self::$checkStatusObject = [
            'object' => $class,
            'method' => $method
        ];
    }

    /**
     * Make the SideNav group
     *
     * @author <NAME> <<EMAIL>>
     * @since  19 Sep 2016
     * @param  $group
     * @param  $callback
     */
    public static function group($group, $callback)
    {
        // set group menu name
        self::$group = $group;

        // set group menu
        self::$menu[$group] = [];

        // run callback function
        $callback();
    }

    /**
     * Register a new menu item
     *
     * @author <NAME> <<EMAIL>>
     * @since  19 Sep 2016
     * @param  $route
     * @param  $callback
     */
    public static function register($route, $callback)
    {
        // set current route
        self::$currentRoute = $route;

        // register route
        self::$routes[self::$currentRoute] = [];

        // make menu array
        $array = self::add($route, $callback);

        if (self::checkGroupId(self::$group)) {
            // add to the group render array
            array_push(self::$menu[self::$group], $array);
        }

        // add to the single render array
        array_push(self::$menu, $array);
    }

    /**
     * Register a new menu item
     *
     * @author <NAME> <<EMAIL>>
     * @since  19 Sep 2016
     * @param  $route
     * @param  $callback
     * @param  $checkCallback
     */
    public static function registerWithCheck($route , $callback , $checkCallback = null)
    {
        // check status of route
        if (self::checkStatus($route, $checkCallback)) {
            self::register($route, $callback);
        }
    }

    /**
     * Add the submenu to item
     *
     * @author <NAME> <<EMAIL>>
     * @since  19 Sep 2016
     * @param  $route
     * @param  $callback
     * @return array
     */
    public static function addSub($route, $callback)
    {
        // register route name
        array_push(self::$routes[self::$currentRoute], $route);

        // return submenu array
        return self::add($route, $callback);
    }

    /**
     * Add the menu item
     *
     * @author <NAME> <<EMAIL>>
     * @since  19 Sep 2016
     * @param  $route
     * @param  $callback
     * @return array
     */
    private static function add($route,$callback)
    {
        // instance of menu class
        $menu = new Menu;

        // run callback function
        $callback($menu);

        // Make the menu object array
        return $menu->make($route);
    }

    /**
     * Get all routes
     *
     * @author <NAME> <<EMAIL>>
     * @since  19 Sep 2016
     * @return array
     */
    public static function routes($index = null)
    {
        if($index !== null) {
            return self::$routes[$index];
        }

        // return array of all routes-name
        return self::$routes;
    }


    /**
     * Render the menu items
     *
     * @author <NAME> <<EMAIL>>
     * @since  19 Sep 2016
     * @param  $type
     * @return mixed
     */
    public static function render($type = null)
    {
        // check $type was used
        if(isset($type)) {
            // return group menu
            return self::$menu[$type];
        }

        // return single menu array
        return self::$menu;
    }

    /**
     * Check group id
     *
{'fraction_non_alphanumeric': 0.12817121558254177, 'fraction_numerical': 0.0134663941324997, 'mean_word_length': 1.7506613756613756, 'pattern_counts': {'":': 0, '<': 59, '<?xml version=': 0, '>': 63, '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': '1405508', 'n_tokens_mistral': 2490, 'n_tokens_neox': 2384, 'n_words': 701}