Code Duplication    Length = 6-7 lines in 2 locations

src/Models/Role.php 1 location

@@ 141-146 (lines=6) @@
138
            $permission = app(Permission::class)->findByName($permission, $this->getDefaultGuardName());
139
        }
140
141
        if (! $this->getGuardNames()->contains($permission->guard_name)) {
142
            $expected = $this->getGuardNames();
143
            $given    = $permission->guard_name;
144
145
            throw new GuardDoesNotMatch($this->helpers->getGuardDoesNotMatchMessage($expected, $given));
146
        }
147
148
        return $this->permissions->contains('id', $permission->id);
149
    }

src/Traits/HasPermissions.php 1 location

@@ 145-151 (lines=7) @@
142
     */
143
    protected function ensureModelSharesGuard(Model $roleOrPermission)
144
    {
145
        if (! $this->getGuardNames()->contains($roleOrPermission->guard_name)) {
146
            $expected = $this->getGuardNames();
147
            $given    = $roleOrPermission->guard_name;
148
            $helpers  = new Helpers();
149
150
            throw new GuardDoesNotMatch($helpers->getGuardDoesNotMatchMessage($expected, $given));
151
        }
152
    }
153
154
    /**