Skip to content

Commit

Permalink
Fix code climate issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Sae126V committed Dec 4, 2024
1 parent 01f3cd3 commit 2a8cccf
Showing 1 changed file with 31 additions and 34 deletions.
65 changes: 31 additions & 34 deletions lib/Gocdb_Services/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -568,46 +568,43 @@ public function getEmailTo()
return $emailTo;
}

public function getIdentityProvidersInfo(): array
public function getIdentityProvidersInfo()
{
$localInfo = $this->GetLocalInfoXML();
$configured_providers = $localInfo->identity_providers->provider;
$configuredProviders = $localInfo->identity_providers->provider;
$identityProviders = [];

if (!empty($configured_providers)) {
foreach ($configured_providers as $providerDetails) {
/** idp */
$idp = (string) $providerDetails->idp;

/** name */
$name = (string) $providerDetails->name;

/** authentication_realm */
$authenticationRealm = [(string) $providerDetails->authentication_realm];

/** required_groups */
$requiredGroups = [];
if ($providerDetails->required_groups) {
foreach (
$providerDetails->required_groups->group as $group
) {
$requiredGroups[] = (string) $group;
}
}

/** help_url */
$helpURL = (string) $providerDetails->help_url;

$identityProviders[] = [
'idp' => $idp,
'name' => $name,
'authenticationRealm' => $authenticationRealm,
'requiredGroups' => $requiredGroups,
'helpURL', $helpURL
];
if (!empty($configuredProviders)) {
foreach ($configuredProviders as $providerDetails) {
$identityProviders[] = $this->extractProviderInfo(
$providerDetails);
}
}

return $identityProviders;
}

private function extractProviderInfo($providerDetails)
{
/** required_groups */
$requiredGroups = [];

if (!empty($providerDetails->required_groups)) {
foreach ($providerDetails->required_groups->group as $group) {
$requiredGroups[] = (string) $group;
}
}

// Return extracted provider information as an array
return [
'idp' => (string) $providerDetails->idp,
'name' => (string) $providerDetails->name,
'authenticationRealm' => [
(string) $providerDetails->authentication_realm
],
'requiredGroups' => $requiredGroups,
'helpURL' => (string) $providerDetails->help_url
];
}

}

0 comments on commit 2a8cccf

Please sign in to comment.