SimpleAttributeEnricher::process()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 3.072

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 4
c 1
b 0
f 0
nc 3
nop 2
dl 0
loc 8
ccs 4
cts 5
cp 0.8
crap 3.072
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace DMK\MKSamlAuth\Enricher;
6
7
use DMK\MKSamlAuth\Model\FrontendUser;
8
9
class SimpleAttributeEnricher implements EnricherInterface
10
{
11
    private $map = [
12
        'givenname' => 'first_name',
13
        'sn' => 'last_name',
14
        'mail' => 'email',
15
    ];
16
17 1
    public function process(FrontendUser $user, array $context)
18
    {
19 1
        foreach ($context['attributes'] as $key => $value) {
20 1
            if (!\array_key_exists($key, $this->map)) {
21
                continue;
22
            }
23
24 1
            $user->setProperty($this->map[$key], $value);
25
        }
26 1
    }
27
}
28