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 setCurrentUser(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

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