<commit_before><?php

namespace Orchid\Platform\Menu;

use Illuminate\Support\Facades\Auth;

class Menu
{
    /**
     * The contents of the menu.
     *
     * @var
     */
    public $container;

    /**
     *  Position menu.
     *
     * @var
     */
    private $location;

    /**
     * Arguments menu form
     * For the transfer of Views.
     *
     * @var
     */
    private $arg;

    /**
     * Sort menu item.
     *
     * @var
     */
    private $sort;

    /**
     * Synthesis element.
     *
     * @var
     */
    private $item;

    /**
     * DashboardMenu constructor.
     */
    public function __construct()
    {
        $this->container = collect();
    }

    /**
     * Setting the menu position.
     *
     * @param $location
     *
     * @return Menu
     */
    public function place(string $location) : Menu
    {
        $this->location = $location;

        return $this;
    }

    /**
     * @param $template
     *
     * @return Menu
     */
    public function template(string $template) : Menu
    {
        $this->template = $template;

        return $this;
    }

    /**
     * @param $arg
     *
     * @return $this
     */
    public function with($arg)
    {
        $this->arg = $arg;

        return $this;
    }

    /**
     * @param $sort
     *
     * @return Menu
     */
    public function sortBy(int $sort) : Menu
    {
        $this->sort = $sort;

        return $this;
    }

    /**
     * Adding a new element to the container.
     *
     * @param string $place
     * @param        $arg
     */
    public function add(string $place, array $arg)
    {
        $arg = array_merge([
            'icon'    => 'fa fa-file-o',
            'childs'  => false,
            'divider' => false,
            'sort'    => 0,
        ], $arg);

        $this->location = $place;
        $this->arg = $arg;
        $this->sort = $arg['sort'];

        $this->item = [
            'location' => $this->location,
            'arg'      => $this->arg,
            'sort'     => $this->sort,
        ];

        $this->container->push($this->item);
    }

    /**
     * Generate on the menu display.
     *
     * @param string      $location
     * @param string|null $template
     *
     * @return string
     */
    public function render(string $location, string $template = null) : string
    {
        $html = '';

        if (!isset($this->user)) {
            $this->user = Auth::user();
            $user = $this->user;
            $this->container = $this->container->filter(function ($item) use ($user) {
                return (isset($item['arg']['permission'])) ? $user->hasAccess($item['arg']['permission']) : true;
            });
        }

        foreach ($this->container->where('location', $location)->sortBy('sort') as $key => $value) {
            if (!array_key_exists('template', $value)) {
                $value['template'] = 'dashboard::partials.leftMainMenu';
            }<commit_msg>- Added key for menu<commit_after><?php

namespace Orchid\Platform\Menu;

use Illuminate\Support\Facades\Auth;

class Menu
{
    /**
     * The contents of the menu.
     *
     * @var
     */
    public $container;

    /**
     *  Position menu.
     *
     * @var
     */
    private $location;

    /**
     * Arguments menu form
     * For the transfer of Views.
     *
     * @var
     */
    private $arg;

    /**
     * Sort menu item.
     *
     * @var
     */
    private $sort;

    /**
     * Synthesis element.
     *
     * @var
     */
    private $item;

    /**
     * DashboardMenu constructor.
     */
    public function __construct()
    {
        $this->container = collect();
    }

    /**
     * Setting the menu position.
     *
     * @param $location
     *
     * @return Menu
     */
    public function place(string $location) : Menu
    {
        $this->location = $location;

        return $this;
    }

    /**
     * @param $template
     *
     * @return Menu
     */
    public function template(string $template) : Menu
    {
        $this->template = $template;

        return $this;
    }

    /**
     * @param $arg
     *
     * @return $this
     */
    public function with($arg)
    {
        $this->arg = $arg;

        return $this;
    }

    /**
     * @param $sort
     *
     * @return Menu
     */
    public function sortBy(int $sort) : Menu
    {
        $this->sort = $sort;

        return $this;
    }

    /**
     * Adding a new element to the container.
     *
     * @param string $place
     * @param        $arg
     */
    public function add(string $place, array $arg)
    {
        $arg = array_merge([
            'icon'    => 'fa fa-file-o',
            'childs'  => false,
            'divider' => false,
            'sort'    => 0,
        ], $arg);

        $this->location = $place;
        $this->arg = $arg;
        $this->sort = $arg['sort'];

        $this->item = [
            'location' => $this->location,
            'arg'      => $this->arg,
            'sort'     => $this->sort,
        ];

        $this->container[$this->arg['slug']] = $this->item;
    }

    /**
     * Generate on the menu display.
     *
     * @param string      $location
     * @param string|null $template
     *
     * @return string
     */
    public function render(string $location, string $template = null) : string
    {
        $html = '';

        if (!isset($this->user)) {
            $this->user = Auth::user();
            $user = $this->user;
            $this->container = $this->container->filter(function ($item) use ($user) {
                return (isset($item['arg']['permission'])) ? $user->hasAccess($item['arg']['permission']) : true;
            });
        }

        foreach ($this->container->where('location', $location)->sortBy('sort') as $key => $value) {
            if (!array_key_exists('template', $value)) {
                $value['template'] = 'dashboard::partials.leftMainMenu';
            }
{'fraction_non_alphanumeric': 0.1574446680080483, 'fraction_numerical': 0.00033534540576794097, 'mean_word_length': 1.4751037344398341, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 69, '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': '6841387', 'n_tokens_mistral': 1835, 'n_tokens_neox': 1784, 'n_words': 395}