| Conditions | 5 | 
| Paths | 6 | 
| Total Lines | 26 | 
| Code Lines | 14 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 0 | ||
| 1 | <?php | ||
| 33 | public static function makeFromApiResponse(array $response): MojangAccount | ||
| 34 |     { | ||
| 35 | $uuid = $response['id']; | ||
| 36 | $username = $response['name']; | ||
| 37 | $skin = ''; | ||
| 38 | $cape = ''; | ||
| 39 | |||
| 40 |         if (\array_key_exists('properties', $response)) { | ||
| 41 |             $textures = \array_filter($response['properties'], static function ($entry) { | ||
| 42 | return $entry['name'] === 'textures'; | ||
| 43 | }); | ||
| 44 | |||
| 45 |             if (!empty($textures)) { | ||
| 46 | $textureData = \json_decode(\base64_decode($textures[0]['value'], true), true, 512, JSON_THROW_ON_ERROR); | ||
| 47 | |||
| 48 |                 if (isset($textureData['textures']['SKIN']['url'])) { | ||
| 49 | $skin = self::extractTextureIdFromUrl($textureData['textures']['SKIN']['url']); | ||
| 50 | } | ||
| 51 | |||
| 52 |                 if (isset($textureData['textures']['CAPE']['url'])) { | ||
| 53 | $cape = self::extractTextureIdFromUrl($textureData['textures']['CAPE']['url']); | ||
| 54 | } | ||
| 55 | } | ||
| 56 | } | ||
| 57 | |||
| 58 | return new MojangAccount($uuid, $username, $skin, $cape); | ||
| 59 | } | ||
| 61 |