Conditions | 3 |
Paths | 4 |
Total Lines | 26 |
Code Lines | 15 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
38 | public function prepareUser(): ?User |
||
39 | { |
||
40 | $user = null; |
||
41 | $parser = $this->parser(); |
||
42 | |||
43 | $profileData = $parser->profileData(); |
||
44 | $tokenData = ['type' => $this->provider] + $parser->tokenData(); |
||
45 | |||
46 | if ($provider = UserProvider::find()->provider($this->provider, $this->providerId)->one()) { |
||
47 | $user = $provider->user; |
||
48 | |||
49 | // if exist then update access tokens |
||
50 | $provider->setAttributes($tokenData); |
||
51 | $provider->save(); |
||
52 | } |
||
53 | |||
54 | if (!is_object($user)) { |
||
55 | $user = new User(); |
||
56 | |||
57 | $user->email = $parser->email(); |
||
58 | $user->setProfile($profileData); |
||
59 | $user->setProviders($tokenData); |
||
60 | } |
||
61 | |||
62 | return $user; |
||
63 | } |
||
64 | |||
71 |
If you access a property on an interface, you most likely code against a concrete implementation of the interface.
Available Fixes
Adding an additional type check:
Changing the type hint: