<commit_before><?php

namespace Stevebauman\Maintenance\Http\Middleware;

use Closure;
use Illuminate\Http\Request;
use Stevebauman\Maintenance\Models\User;
use Stevebauman\Maintenance\Services\SentryService;

class PermissionMiddleware
{
    /**
     * @var SentryService
     */
    protected $sentry;

    /**
     * Constructor.
     *
     * @param SentryService $sentry
     */
    public function __construct(SentryService $sentry)
    {
        $this->sentry = $sentry;
    }

    /**
     * Throws 403 unauthorized error if the user is
     * not allowed to access the specified route.
     *
     * @param Request $request
     * @param Closure $next
     *
     * @return Request
     *
     * @throws \Symfony\Component\HttpKernel\Exception\HttpException
     * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
     */
    public function handle(Request $request, Closure $next)
    {
        $user = $this->sentry->getCurrentUser();

        if($user && $user instanceof User) {
            if($user->hasAccess($request->route()->getName())) {
                return $next($request);
            }
        }

        // Return unauthorized error.
        abort(403);
    }
}<commit_msg>Fix typo<commit_after><?php

namespace Stevebauman\Maintenance\Http\Middleware;

use Closure;
use Illuminate\Http\Request;
use Stevebauman\Maintenance\Models\User;
use Stevebauman\Maintenance\Services\SentryService;

class PermissionMiddleware
{
    /**
     * @var SentryService
     */
    protected $sentry;

    /**
     * Constructor.
     *
     * @param SentryService $sentry
     */
    public function __construct(SentryService $sentry)
    {
        $this->sentry = $sentry;
    }

    /**
     * Throws 403 unauthorized error if the user is
     * not allowed to access the specified route.
     *
     * @param Request $request
     * @param Closure $next
     *
     * @return Request
     *
     * @throws \Symfony\Component\HttpKernel\Exception\HttpException
     * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
     */
    public function handle(Request $request, Closure $next)
    {
        $user = $this->sentry->getCurrentUser();

        if($user && $user instanceof User) {
            if($user->hasAccess($request->route()->getName())) {
                return $next($request);
            }
        }

        // Return forbidden error.
        abort(403);
    }
}

{'fraction_non_alphanumeric': 0.1159062885326757, 'fraction_numerical': 0.004932182490752158, 'mean_word_length': 2.3296853625171, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 15, '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': '5002350', 'n_tokens_mistral': 718, 'n_tokens_neox': 698, 'n_words': 147}