| Conditions | 2 |
| Paths | 2 |
| Total Lines | 19 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 28 | public static function fromGitterObject($attributes) |
||
| 29 | { |
||
| 30 | $values = (new AttributeMapper((array)$attributes)) |
||
| 31 | ->rename('id', 'gitter_id') |
||
| 32 | ->rename('username', 'login') |
||
| 33 | ->rename('displayName', 'name') |
||
| 34 | ->rename('avatarUrlMedium', 'avatar') |
||
| 35 | ->only(['gitter_id', 'login', 'name', 'avatar', 'url']) |
||
| 36 | ->toArray(); |
||
| 37 | |||
| 38 | $user = User::where('gitter_id', $values['gitter_id'])->first(); |
||
| 39 | if (!$user) { |
||
| 40 | $user = User::unguarded(function () use ($values) { |
||
| 41 | return User::create($values); |
||
| 42 | }); |
||
| 43 | } |
||
| 44 | |||
| 45 | return $user; |
||
| 46 | } |
||
| 47 | } |
||
| 48 |