Code Duplication    Length = 6-7 lines in 2 locations

src/Models/Role.php 1 location

@@ 133-138 (lines=6) @@
130
            $permission = app(Permission::class)->findByName($permission, $this->getDefaultGuardName());
131
        }
132
133
        if (! $this->getGuardNames()->contains($permission->guard_name)) {
134
            $expected = $this->getGuardNames();
135
            $given    = $permission->guard_name;
136
137
            throw new GuardDoesNotMatch($this->helpers->getGuardDoesNotMatchMessage($expected, $given));
138
        }
139
140
        return $this->permissions->contains('id', $permission->id);
141
    }

src/Traits/HasPermissions.php 1 location

@@ 127-133 (lines=7) @@
124
     */
125
    protected function ensureModelSharesGuard(Model $roleOrPermission)
126
    {
127
        if (! $this->getGuardNames()->contains($roleOrPermission->guard_name)) {
128
            $expected = $this->getGuardNames();
129
            $given    = $roleOrPermission->guard_name;
130
            $helpers  = new Helpers();
131
132
            throw new GuardDoesNotMatch($helpers->getGuardDoesNotMatchMessage($expected, $given));
133
        }
134
    }
135
136
    protected function getGuardNames(): Collection