Conditions | 3 |
Paths | 3 |
Total Lines | 27 |
Code Lines | 14 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 12 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
24 | public function updateOrCreate(array $attributes, array $record) |
||
25 | { |
||
26 | $userFolder = $record['user_folder']; |
||
27 | |||
28 | if (!($attributes['uid'] ?? false)) { |
||
29 | throw new \LogicException('The idp does not return any "uid". Please check the configuration in the idp settings.'); |
||
30 | } |
||
31 | |||
32 | $user = $this->manager->getRepository()->findByUsername($attributes['uid'], $record['user_folder']); |
||
33 | |||
34 | if (null === $user) { |
||
35 | $user = new FrontendUser([ |
||
36 | 'username' => $attributes['uid'], |
||
37 | 'pid' => $userFolder, |
||
38 | ]); |
||
39 | } |
||
40 | |||
41 | unset($attributes['uid']); |
||
42 | |||
43 | $this->enrichers->process($user, [ |
||
44 | 'idp' => $record, |
||
45 | 'attributes' => $attributes, |
||
46 | ]); |
||
47 | |||
48 | $this->manager->save($user); |
||
49 | |||
50 | return $user; |
||
51 | } |
||
53 |