Passed
Push — master ( 139939...b4b8e8 )
by Arthur
21:54 queued 17s
created

UserTestRoles::setUp()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 5
nc 2
nop 0
dl 0
loc 8
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: arthur
5
 * Date: 05.03.19
6
 * Time: 13:08
7
 */
8
9
namespace Modules\Authorization\Traits;
10
11
12
use Modules\Authorization\Entities\Role;
13
14
trait UserTestRoles
15
{
16
    public function setUp(): void
17
    {
18
        parent::setUp();
19
20
        if (isset($this->roles)) {
21
            $this->setUserRoles($this->roles);
22
        } else {
23
            $this->setUserRoles(Role::GUEST);
24
        }
25
    }
26
27
28
    protected function setUserRoles($roles)
29
    {
30
        $this->getActingUser()->syncRoles($roles);
0 ignored issues
show
Bug introduced by
It seems like getActingUser() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

30
        $this->/** @scrutinizer ignore-call */ 
31
               getActingUser()->syncRoles($roles);
Loading history...
31
    }
32
}
33