Olivier Massot 1 年之前
父節點
當前提交
45bff4a4ec

+ 3 - 3
src/EventListener/OnKernelRequestPreRead.php

@@ -16,8 +16,8 @@ use Symfony\Component\HttpKernel\KernelEvents;
 class OnKernelRequestPreRead implements EventSubscriberInterface
 {
     public function __construct(
-        private RequestStack                $requestStack,
-        private Security                    $security,
+        private RequestStack $requestStack,
+        private Security $security,
         private FiltersConfigurationService $filtersConfigurationService,
         private readonly ObjectUtils $objectUtils
     ) {
@@ -52,7 +52,7 @@ class OnKernelRequestPreRead implements EventSubscriberInterface
             }
 
             $profileHash = $event->getRequest()->headers->get('profileHash');
-            if ($profileHash !== null) {
+            if (null !== $profileHash) {
                 $profileMask = [
                     'activityYear' => $access->getActivityYear(),
                     'historical' => $access->getHistorical(),

+ 5 - 6
src/Service/Utils/ObjectUtils.php

@@ -6,19 +6,18 @@ class ObjectUtils
 {
     /**
      * Créé un hash à partir d'un objet
-     * (après l'avoir trié selon ses clés, et convertit en json sans espace)
+     * (après l'avoir trié selon ses clés, et convertit en json sans espace).
      *
      * @param object|array<mixed> $instance
-     * @param string $algorithm
-     * @return string
      */
-    public static function hash(object | array $instance, string $algorithm = 'sha256'): string
+    public static function hash(object|array $instance, string $algorithm = 'sha256'): string
     {
         // Convertit l'objet en tableau associatif
-        $array = (array)$instance;
+        $array = (array) $instance;
         // Puis trie l'objet selon ses clés, encode en json, et hash
         ksort($array);
-        $json = json_encode((object)$array);
+        $json = json_encode((object) $array);
+
         return hash($algorithm, $json);
     }
 }

+ 1 - 1
tests/Unit/Service/Utils/ObjectUtilsTest.php

@@ -47,7 +47,7 @@ class ObjectUtilsTest extends TestCase
     {
         $this->assertEquals(
             'e6a3385fb77c287a712e7f406a451727f0625041823ecf23bea7ef39b2e39805',
-            ObjectUtils::hash((object)['a' => 1, 'b' => 2, 'c' => 3])
+            ObjectUtils::hash((object) ['a' => 1, 'b' => 2, 'c' => 3])
         );
     }
 }