MapUser   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 2
dl 0
loc 25
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
use craft\elements\User;
7
use flipbox\saml\core\records\AbstractProvider;
8
9
/**
10
 * Trait MapUser
11
 * @package flipbox\saml\core\records\traits
12
 * @mixin AbstractProvider
13
 */
14
trait MapUser
15
{
16
    /**
17
     * Current only used on the IDP side with this provider being the SP
18
     *
19
     * @param User $user
20
     * @return string|null
21
     * @throws \Throwable
22
     * @throws \yii\base\Exception
23
     */
24
    public function assignNameId(User $user)
25
    {
26
        // Defaults to username
27
        $nameId = $user->username;
28
29
        if ($this->nameIdOverride) {
30
            $nameId = \Craft::$app->view->renderObjectTemplate(
31
                $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...
32
                $user
33
            );
34
        }
35
36
        return $nameId;
37
    }
38
}
39