Completed
Push — master ( 0ca4f0...992805 )
by Damien
07:27
created

MapUser   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 2
dl 0
loc 26
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A assignNameId() 0 14 2
1
<?php
2
3
4
namespace flipbox\saml\core\records\traits;
5
6
7
use craft\elements\User;
8
use flipbox\saml\core\records\AbstractProvider;
9
10
/**
11
 * Trait MapUser
12
 * @package flipbox\saml\core\records\traits
13
 * @mixin AbstractProvider
14
 */
15
trait MapUser
16
{
17
    /**
18
     * Current only used on the IDP side with this provider being the SP
19
     *
20
     * @param User $user
21
     * @return string|null
22
     * @throws \Throwable
23
     * @throws \yii\base\Exception
24
     */
25
    public function assignNameId(User $user)
26
    {
27
        // Defaults to username
28
        $nameId = $user->username;
29
30
        if ($this->nameIdOverride) {
31
            $nameId = \Craft::$app->view->renderObjectTemplate(
32
                $this->nameIdOverride,
0 ignored issues
show
Bug introduced by
The property nameIdOverride does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
33
                $user
34
            );
35
        }
36
37
        return $nameId;
38
    }
39
40
}