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