From d43152f127cf3e4cf3bb072f7548062b1f8c0481 Mon Sep 17 00:00:00 2001 From: Pol Dellaiera <pol.dellaiera@protonmail.com> Date: Tue, 1 Sep 2020 14:36:08 +0200 Subject: [PATCH] Minor code simplification. --- src/Security/Core/User/EuLoginUser.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Security/Core/User/EuLoginUser.php b/src/Security/Core/User/EuLoginUser.php index 802b322..2a15945 100644 --- a/src/Security/Core/User/EuLoginUser.php +++ b/src/Security/Core/User/EuLoginUser.php @@ -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; -- GitLab