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

AttributeMap::renderValue()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 14
rs 9.7998
c 0
b 0
f 0
cc 2
nc 2
nop 1
1
<?php
2
3
4
namespace flipbox\saml\core\models;
5
6
use craft\elements\User;
7
use yii\base\Model;
8
9
class AttributeMap extends Model
10
{
11
    /**
12
     * @var string
13
     */
14
    public $craftProperty;
15
    /**
16
     * @var string
17
     */
18
    public $attributeName;
19
    /**
20
     * @var string
21
     */
22
    public $templateOverride;
23
24
    public function renderValue(User $user)
25
    {
26
        $value = null;
0 ignored issues
show
Unused Code introduced by
$value is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
27
        if ($this->templateOverride) {
28
            $value = \Craft::$app->view->renderObjectTemplate(
29
                $this->templateOverride,
30
                $user
31
            );
32
        } else {
33
            $value = $user->{$this->craftProperty};
34
        }
35
36
        return $value;
37
    }
38
}