Code Duplication    Length = 12-12 lines in 2 locations

src/Models/Role.php 2 locations

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