From 51966acf16039d39f43f6d292bba0befb81e0956 Mon Sep 17 00:00:00 2001
From: Christoph Reiter <reiter.christoph@gmail.com>
Date: Wed, 30 Nov 2022 10:50:34 +0100
Subject: [PATCH] Rename customAttributes to just attributes

These are all the attributes we have now.
---
 src/Authorization/AuthorizationDataMuxer.php     | 16 ++++++++--------
 .../AuthorizationExpressionChecker.php           |  2 +-
 src/Authorization/DebugCommand.php               |  2 +-
 3 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/src/Authorization/AuthorizationDataMuxer.php b/src/Authorization/AuthorizationDataMuxer.php
index 4970593..424d35d 100644
--- a/src/Authorization/AuthorizationDataMuxer.php
+++ b/src/Authorization/AuthorizationDataMuxer.php
@@ -10,7 +10,7 @@ class AuthorizationDataMuxer
     private $authorizationDataProviders;
 
     /** @var array */
-    private $customAttributes;
+    private $attributes;
 
     /**
      * @param iterable<AuthorizationDataProviderInterface> $authorizationDataProviders
@@ -18,7 +18,7 @@ class AuthorizationDataMuxer
     public function __construct(iterable $authorizationDataProviders)
     {
         $this->authorizationDataProviders = $authorizationDataProviders;
-        $this->customAttributes = [];
+        $this->attributes = [];
     }
 
     private function loadUserAttributesFromAuthorizationProvider(?string $userIdentifier, AuthorizationDataProviderInterface $authorizationDataProvider): void
@@ -27,7 +27,7 @@ class AuthorizationDataMuxer
 
         foreach ($authorizationDataProvider->getAvailableAttributes() as $availableAttribute) {
             if (array_key_exists($availableAttribute, $userAttributes)) {
-                $this->customAttributes[$availableAttribute] = $userAttributes[$availableAttribute];
+                $this->attributes[$availableAttribute] = $userAttributes[$availableAttribute];
             }
         }
     }
@@ -55,19 +55,19 @@ class AuthorizationDataMuxer
      *
      * @throws AuthorizationException
      */
-    public function getCustomAttribute(?string $userIdentifier, string $attributeName, $defaultValue = null)
+    public function getAttribute(?string $userIdentifier, string $attributeName, $defaultValue = null)
     {
-        if (array_key_exists($attributeName, $this->customAttributes) === false) {
-            $this->loadCustomAttribute($userIdentifier, $attributeName);
+        if (array_key_exists($attributeName, $this->attributes) === false) {
+            $this->loadAttribute($userIdentifier, $attributeName);
         }
 
-        return $this->customAttributes[$attributeName] ?? $defaultValue;
+        return $this->attributes[$attributeName] ?? $defaultValue;
     }
 
     /**
      * @throws AuthorizationException
      */
-    private function loadCustomAttribute(?string $userIdentifier, string $attributeName): void
+    private function loadAttribute(?string $userIdentifier, string $attributeName): void
     {
         $wasFound = false;
         foreach ($this->authorizationDataProviders as $authorizationDataProvider) {
diff --git a/src/Authorization/AuthorizationExpressionChecker.php b/src/Authorization/AuthorizationExpressionChecker.php
index 1eb3734..2363d9e 100644
--- a/src/Authorization/AuthorizationExpressionChecker.php
+++ b/src/Authorization/AuthorizationExpressionChecker.php
@@ -77,7 +77,7 @@ class AuthorizationExpressionChecker
      */
     public function getCustomAttribute(AuthorizationUser $currentAuthorizationUser, string $attributeName, $defaultValue = null)
     {
-        return $this->dataMux->getCustomAttribute($currentAuthorizationUser->getIdentifier(), $attributeName, $defaultValue);
+        return $this->dataMux->getAttribute($currentAuthorizationUser->getIdentifier(), $attributeName, $defaultValue);
     }
 
     /**
diff --git a/src/Authorization/DebugCommand.php b/src/Authorization/DebugCommand.php
index 13c0794..619d0ac 100644
--- a/src/Authorization/DebugCommand.php
+++ b/src/Authorization/DebugCommand.php
@@ -46,7 +46,7 @@ class DebugCommand extends Command implements LoggerAwareInterface
         $default = new \stdClass();
         sort($attrs, SORT_STRING | SORT_FLAG_CASE);
         foreach ($attrs as $attr) {
-            $all[$attr] = $mux->getCustomAttribute($username, $attr, $default);
+            $all[$attr] = $mux->getAttribute($username, $attr, $default);
         }
 
         // Now print them out
-- 
GitLab