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

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