Code Duplication    Length = 13-13 lines in 2 locations

src/Models/Permission.php 1 location

@@ 127-139 (lines=13) @@
124
     * @return PermissionInterface
125
     * @throws PermissionDoesNotExist
126
     */
127
    public static function findByName(string $name, $guardName = null): PermissionInterface
128
    {
129
        $guardName = $guardName ?? \config('auth.defaults.guard');
130
131
        $permission = static::getPermissions()->where('name', $name)->where('guard_name', $guardName)->first();
132
133
        if (! $permission) {
134
            $helpers = new Helpers();
135
            throw new PermissionDoesNotExist($helpers->getPermissionDoesNotExistMessage($name, $guardName));
136
        }
137
138
        return $permission;
139
    }
140
141
    /**
142
     * Get the current cached permissions.

src/Models/Role.php 1 location

@@ 124-136 (lines=13) @@
121
     * @return RoleInterface
122
     * @throws RoleDoesNotExist
123
     */
124
    public static function findByName(string $name, $guardName = null): RoleInterface
125
    {
126
        $guardName = $guardName ?? \config('auth.defaults.guard');
127
128
        $role = static::where('name', $name)
129
                      ->where('guard_name', $guardName)
130
                      ->first();
131
132
        if (! $role) {
133
            $helpers = new Helpers();
134
            throw new RoleDoesNotExist($helpers->getRoleDoesNotExistMessage($name, $guardName));
135
        }
136
137
        return $role;
138
    }
139