Code development platform for open source projects from the European Union institutions

Skip to content
Snippets Groups Projects
Commit d43152f1 authored by Pol Dellaiera's avatar Pol Dellaiera
Browse files

Minor code simplification.

parent 26af1840
No related branches found
Tags 1.3.5
No related merge requests found
......@@ -59,7 +59,7 @@ final class EuLoginUser implements EuLoginUserInterface
{
$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'],
......@@ -67,22 +67,22 @@ final class EuLoginUser implements EuLoginUserInterface
['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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment