$graphUser Antwort von /me bzw. /users/{id} * @return array */ public static function fromGraph(array $graphUser, ?string $managerSubject = null, bool $withManager = false): array { $profile = [ 'display_name' => $graphUser['displayName'] ?? null, 'first_name' => $graphUser['givenName'] ?? null, 'last_name' => $graphUser['surname'] ?? null, 'email' => $graphUser['mail'] ?? (str_contains((string) ($graphUser['userPrincipalName'] ?? ''), '#EXT#') ? null : ($graphUser['userPrincipalName'] ?? null)), 'job_title' => $graphUser['jobTitle'] ?? null, 'department' => $graphUser['department'] ?? null, 'location' => $graphUser['officeLocation'] ?? null, 'phone' => $graphUser['businessPhones'][0] ?? null, 'mobile' => $graphUser['mobilePhone'] ?? null, ]; if ($withManager) { $profile['manager_subject'] = $managerSubject; } return $profile; } /** * Rückfall, wenn Graph nicht erreichbar ist: Angaben aus dem ID-Token. * * @param array $claims * @return array */ public static function fromClaims(array $claims): array { return [ 'display_name' => $claims['name'] ?? null, 'first_name' => $claims['given_name'] ?? null, 'last_name' => $claims['family_name'] ?? null, 'email' => $claims['email'] ?? $claims['preferred_username'] ?? null, ]; } }