Code Duplication    Length = 9-9 lines in 2 locations

src/Middleware/Authentication.php 1 location

@@ 74-82 (lines=9) @@
71
     * @param UserVO $user
72
     * @throws MethodNotAllowedException
73
     */
74
    protected function checkForRole(Route $route, UserVO $user) : void
75
    {
76
        if ($route->hasDefault('_role')) {
77
            $role = $route->getDefault('_role');
78
            if (!in_array($role, $user->roles, true)) {
79
                throw new MethodNotAllowedException([], sprintf('Need role %s', $role));
80
            }
81
        }
82
    }
83
84
    /**
85
     * @param int $userId

src/Middleware/TokenAuthentication.php 1 location

@@ 70-78 (lines=9) @@
67
     * @param UserVO $user
68
     * @throws MethodNotAllowedException
69
     */
70
    protected function checkForRole(Route $route, UserVO $user)
71
    {
72
        if ($route->hasDefault('_role')) {
73
            $role = $route->getDefault('_role');
74
            if (!in_array($role, $user->roles, true)) {
75
                throw new MethodNotAllowedException([], sprintf('Need role %s', $role));
76
            }
77
        }
78
    }
79
80
    /**
81
     * @param int $userId