Skip to content

Commit

Permalink
Minor code simplification.
Browse files Browse the repository at this point in the history
  • Loading branch information
drupol committed Sep 1, 2020
1 parent 26af184 commit d43152f
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/Security/Core/User/EuLoginUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,30 +59,30 @@ public function getAttributes(): array
{
$attributes = $this->user->getAttributes();

// @Todo Ugly. Refactor this when JSON format will be available.
/** @Todo Ugly. Refactor this when JSON format will be available. */
$propertyToMangle = [
['extendedAttributes', 'extendedAttribute'],
['groups', 'group'],
['strengths', 'strength'],
['authenticationFactors', 'authenticationFactor'],
];

foreach ($propertyToMangle as $properties) {
if (!array_key_exists($properties[0], $attributes)) {
foreach ($propertyToMangle as [$parent, $child]) {
if (!array_key_exists($parent, $attributes)) {
continue;
}

if (!array_key_exists($properties[1], $attributes[$properties[0]])) {
if (!array_key_exists($child, $attributes[$parent])) {
continue;
}

$attributes[$properties[0]][$properties[1]] = (array) $attributes[$properties[0]][$properties[1]];
$attributes[$parent][$child] = (array) $attributes[$parent][$child];

if (array_key_exists(0, $attributes[$properties[0]][$properties[1]])) {
if (array_key_exists(0, $attributes[$parent][$child])) {
continue;
}

$attributes[$properties[0]][$properties[1]] = [$attributes[$properties[0]][$properties[1]]];
$attributes[$parent][$child] = [$attributes[$parent][$child]];
}

return $attributes;
Expand Down

0 comments on commit d43152f

Please sign in to comment.