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