| Conditions | 6 |
| Paths | 9 |
| Total Lines | 32 |
| Code Lines | 20 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 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 | |||
| 65 | private function parser() |
||
| 66 | { |
||
| 67 | $parserClass = $this->parsers[$this->client->id]; |
||
| 68 | return new $parserClass($this->client); |
||
| 69 | } |
||
| 70 | } |
||
| 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: