Code Duplication    Length = 15-17 lines in 2 locations

eZ/Publish/Core/Repository/PermissionService.php 1 location

@@ 119-133 (lines=15) @@
116
        return $this->currentUserRef;
117
    }
118
119
    public function setCurrentUserReference(APIUserReference $user)
120
    {
121
        $id = $user->getUserId();
122
        if (!$id) {
123
            throw new InvalidArgumentValue('$user->getUserId()', $id);
124
        }
125
126
        if ($user instanceof User) {
127
            $this->currentUser = $user;
128
            $this->currentUserRef = new UserReference($id);
129
        } else {
130
            $this->currentUser = null;
131
            $this->currentUserRef = $user;
132
        }
133
    }
134
135
    public function hasAccess($module, $function, APIUserReference $user = null)
136
    {

eZ/Publish/Core/Repository/Repository.php 1 location

@@ 340-356 (lines=17) @@
337
     *
338
     * @throws InvalidArgumentValue If UserReference does not contain a id
339
     */
340
    public function setCurrentUser(APIUserReference $user)
341
    {
342
        $id = $user->getUserId();
343
        if (!$id) {
344
            throw new InvalidArgumentValue('$user->getUserId()', $id);
345
        }
346
347
        if ($user instanceof User) {
348
            $this->currentUser = $user;
349
            $this->currentUserRef = new UserReference($id);
350
        } else {
351
            $this->currentUser = null;
352
            $this->currentUserRef = $user;
353
        }
354
355
        return $this->getPermissionService()->setCurrentUser($user);
356
    }
357
358
    /**
359
     * Allows API execution to be performed with full access sand-boxed.