<commit_before><?php
namespace Barryvanveen\Composers;

use Illuminate\View\View;
use Route;

class MenuComposer
{
    /** @var  View */
    protected $view;

    /**
     * @param View $view
     */
    public function compose($view)
    {
        $this->view = $view;

        $this->buildDefaultNavigation();

        $this->buildAdminNavigation();
    }

    private function buildDefaultNavigation()
    {
        $menu = [
            [
                'slug'    => route('home'),
                'title'   => 'Blog',
                'routes'  => ['home', 'blog-item'],
                'classnames' => '',
            ],
            [
                'slug'    => route('over-mij'),
                'title'   => 'Over mij',
                'routes'  => ['over-mij', 'boeken'],
                'classnames' => '',
            ],
        ];

        $menu = $this->setActiveMenuItem($menu);

        $this->view->with('mainnav', $menu);
    }

    private function buildAdminNavigation()
    {
        $menu = [
            [
                'slug'    => route('admin.dashboard'),
                'title'   => 'Dashboard',
                'routes'  => ['admin.dashboard'],
                'classnames' => '',
            ],
            [
                'slug'    => route('admin.blog'),
                'title'   => 'Blog',
                'routes'  => ['admin.blog', 'admin.blog-new', 'admin.blog-edit'],
                'classnames' => '',
            ],
            [
                'slug'    => route('admin.page'),
                'title'   => 'Pages',
                'routes'  => ['admin.page', 'admin.page-new', 'admin.page-edit'],
                'classnames' => '',
            ],
            [
                'slug'    => route('admin.logs'),
                'title'   => 'Logs',
                'routes'  => ['admin.logs'],
                'classnames' => '',
            ],
        ];

        $menu = $this->setActiveMenuItem($menu);

        $this->view->with('adminnav', $menu);
    }

    /**
     * Set one menuitem as active based on the routes it belongs to.
     *
     * @param array $menu
     *
     * @return array
     */
    private function setActiveMenuItem($menu)
    {
        foreach($menu as $key=>$menuitem) {
            if (in_array(Route::currentRouteName(), $menuitem['routes'])) {
                $menu[$key]['classnames'] .= ' active';
                break;
            }
        }

        return $menu;
    }
}<commit_msg>php-cs-fixer<commit_after><?php
namespace Barryvanveen\Composers;

use Illuminate\View\View;
use Route;

class MenuComposer
{
    /** @var  View */
    protected $view;

    /**
     * @param View $view
     */
    public function compose($view)
    {
        $this->view = $view;

        $this->buildDefaultNavigation();

        $this->buildAdminNavigation();
    }

    private function buildDefaultNavigation()
    {
        $menu = [
            [
                'slug'       => route('home'),
                'title'      => 'Blog',
                'routes'     => ['home', 'blog-item'],
                'classnames' => '',
            ],
            [
                'slug'       => route('over-mij'),
                'title'      => 'Over mij',
                'routes'     => ['over-mij', 'boeken'],
                'classnames' => '',
            ],
        ];

        $menu = $this->setActiveMenuItem($menu);

        $this->view->with('mainnav', $menu);
    }

    private function buildAdminNavigation()
    {
        $menu = [
            [
                'slug'       => route('admin.dashboard'),
                'title'      => 'Dashboard',
                'routes'     => ['admin.dashboard'],
                'classnames' => '',
            ],
            [
                'slug'       => route('admin.blog'),
                'title'      => 'Blog',
                'routes'     => ['admin.blog', 'admin.blog-new', 'admin.blog-edit'],
                'classnames' => '',
            ],
            [
                'slug'       => route('admin.page'),
                'title'      => 'Pages',
                'routes'     => ['admin.page', 'admin.page-new', 'admin.page-edit'],
                'classnames' => '',
            ],
            [
                'slug'       => route('admin.logs'),
                'title'      => 'Logs',
                'routes'     => ['admin.logs'],
                'classnames' => '',
            ],
        ];

        $menu = $this->setActiveMenuItem($menu);

        $this->view->with('adminnav', $menu);
    }

    /**
     * Set one menuitem as active based on the routes it belongs to.
     *
     * @param array $menu
     *
     * @return array
     */
    private function setActiveMenuItem($menu)
    {
        foreach ($menu as $key => $menuitem) {
            if (in_array(Route::currentRouteName(), $menuitem['routes'])) {
                $menu[$key]['classnames'] .= ' active';
                break;
            }
        }

        return $menu;
    }
}
{'fraction_non_alphanumeric': 0.168, 'fraction_numerical': 0.0, 'mean_word_length': 1.2405913978494623, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 71, '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': '6523772', 'n_tokens_mistral': 1434, 'n_tokens_neox': 1398, 'n_words': 240}