Code Duplication    Length = 12-12 lines in 2 locations

src/Models/Role.php 2 locations

@@ 82-93 (lines=12) @@
79
     *
80
     * @throws \Spatie\Permission\Exceptions\RoleDoesNotExist
81
     */
82
    public static function findByName(string $name, $guardName = null): RoleContract
83
    {
84
        $guardName = $guardName ?? Guard::getDefaultName(static::class);
85
86
        $role = static::where('name', $name)->where('guard_name', $guardName)->first();
87
88
        if (! $role) {
89
            throw RoleDoesNotExist::named($name);
90
        }
91
92
        return $role;
93
    }
94
95
    public static function findById(int $id, $guardName = null): RoleContract
96
    {
@@ 95-106 (lines=12) @@
92
        return $role;
93
    }
94
95
    public static function findById(int $id, $guardName = null): RoleContract
96
    {
97
        $guardName = $guardName ?? Guard::getDefaultName(static::class);
98
99
        $role = static::where('id', $id)->where('guard_name', $guardName)->first();
100
101
        if (! $role) {
102
            throw RoleDoesNotExist::withId($id);
103
        }
104
105
        return $role;
106
    }
107
108
    /**
109
     * Find or create role by its name (and optionally guardName).