Passed
Push — main ( a879dc...6111e3 )
by Dimitri
12:08
created
ResponseCache.php 2 patches
Indentation   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -57,18 +57,18 @@  discard block
 block discarded – undo
57 57
     {
58 58
         $uri = $request->getUri();
59 59
 
60
-		$query = '';
61
-		if ($this->cacheQueryString !== false) {
62
-			parse_str($uri->getQuery(), $queryParams);
63
-
64
-			if (is_array($this->cacheQueryString)) {
65
-				// Filtrer seulement les paramètres spécifiés
66
-				$queryParams = array_intersect_key($queryParams, array_flip($this->cacheQueryString));
67
-			}
68
-			// Trier pour garantir l'ordre et éviter les doublons avec paramètres dans un ordre différent
69
-			ksort($queryParams);
70
-			$query = http_build_query($queryParams);
71
-		}
60
+  $query = '';
61
+  if ($this->cacheQueryString !== false) {
62
+   parse_str($uri->getQuery(), $queryParams);
63
+
64
+   if (is_array($this->cacheQueryString)) {
65
+    // Filtrer seulement les paramètres spécifiés
66
+    $queryParams = array_intersect_key($queryParams, array_flip($this->cacheQueryString));
67
+   }
68
+   // Trier pour garantir l'ordre et éviter les doublons avec paramètres dans un ordre différent
69
+   ksort($queryParams);
70
+   $query = http_build_query($queryParams);
71
+  }
72 72
 
73 73
         return md5($uri->withFragment('')->withQuery($query));
74 74
     }
@@ -91,11 +91,11 @@  discard block
 block discarded – undo
91 91
         return $this->cache->set(
92 92
             $this->generateCacheKey($request),
93 93
             serialize([
94
-				'headers' => $headers,
95
-				'output'  => $response->getBody()->getContents(),
96
-				'status'  => $response->getStatusCode(),
97
-				'reason'  => $response->getReasonPhrase(),
98
-			]),
94
+    'headers' => $headers,
95
+    'output'  => $response->getBody()->getContents(),
96
+    'status'  => $response->getStatusCode(),
97
+    'reason'  => $response->getReasonPhrase(),
98
+   ]),
99 99
             $this->ttl
100 100
         );
101 101
     }
@@ -107,23 +107,23 @@  discard block
 block discarded – undo
107 107
     {
108 108
         if ($cachedResponse = $this->cache->get($this->generateCacheKey($request))) {
109 109
             if (!is_string($cachedResponse)) {
110
-				throw new Exception('Données de cache corrompues');
111
-			}
110
+    throw new Exception('Données de cache corrompues');
111
+   }
112 112
 
113
-			$cachedResponse = unserialize($cachedResponse, ['allowed_classes' => false]);
113
+   $cachedResponse = unserialize($cachedResponse, ['allowed_classes' => false]);
114 114
 
115
-			if (!is_array($cachedResponse) || !isset($cachedResponse['output'], $cachedResponse['headers'])) {
116
-				throw new Exception('Structure de cache invalide');
117
-			}
115
+   if (!is_array($cachedResponse) || !isset($cachedResponse['output'], $cachedResponse['headers'])) {
116
+    throw new Exception('Structure de cache invalide');
117
+   }
118 118
 
119
-			// Validation des headers
120
-			if (!is_array($cachedResponse['headers'])) {
121
-				throw new Exception('Headers de cache invalides');
122
-			}
119
+   // Validation des headers
120
+   if (!is_array($cachedResponse['headers'])) {
121
+    throw new Exception('Headers de cache invalides');
122
+   }
123 123
 
124 124
             $headers = $cachedResponse['headers'];
125 125
             $output  = $cachedResponse['output'];
126
-			$status  = $cachedResponse['status'] ?? 200;
126
+   $status  = $cachedResponse['status'] ?? 200;
127 127
             $reason  = $cachedResponse['reason'] ?? '';
128 128
 
129 129
             // Effacer tous les en-têtes par défaut
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
             }
138 138
 
139 139
             return $response->withBody(to_stream($output))
140
-				->withStatus($status, $reason);
140
+    ->withStatus($status, $reason);
141 141
         }
142 142
 
143 143
         return null;
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
      *                                            Veuillez noter que cela peut entraîner de nombreux fichiers de cache générés encore et encore pour la même page.
38 38
      *                                            array('q') = Activé, mais ne prend en compte que la liste spécifiée de paramètres de requête.
39 39
      */
40
-    public function __construct(private CacheInterface $cache, private array|bool $cacheQueryString = false)
40
+    public function __construct(private CacheInterface $cache, private array | bool $cacheQueryString = false)
41 41
     {
42 42
     }
43 43
 
@@ -82,10 +82,10 @@  discard block
 block discarded – undo
82 82
             return true;
83 83
         }
84 84
 
85
-        $headers = [];
85
+        $headers = [ ];
86 86
 
87 87
         foreach (array_keys($response->getHeaders()) as $header) {
88
-            $headers[$header] = $response->getHeaderLine($header);
88
+            $headers[ $header ] = $response->getHeaderLine($header);
89 89
         }
90 90
 
91 91
         return $this->cache->set(
@@ -110,21 +110,21 @@  discard block
 block discarded – undo
110 110
 				throw new Exception('Données de cache corrompues');
111 111
 			}
112 112
 
113
-			$cachedResponse = unserialize($cachedResponse, ['allowed_classes' => false]);
113
+			$cachedResponse = unserialize($cachedResponse, [ 'allowed_classes' => false ]);
114 114
 
115
-			if (!is_array($cachedResponse) || !isset($cachedResponse['output'], $cachedResponse['headers'])) {
115
+			if (!is_array($cachedResponse) || !isset($cachedResponse[ 'output' ], $cachedResponse[ 'headers' ])) {
116 116
 				throw new Exception('Structure de cache invalide');
117 117
 			}
118 118
 
119 119
 			// Validation des headers
120
-			if (!is_array($cachedResponse['headers'])) {
120
+			if (!is_array($cachedResponse[ 'headers' ])) {
121 121
 				throw new Exception('Headers de cache invalides');
122 122
 			}
123 123
 
124
-            $headers = $cachedResponse['headers'];
125
-            $output  = $cachedResponse['output'];
126
-			$status  = $cachedResponse['status'] ?? 200;
127
-            $reason  = $cachedResponse['reason'] ?? '';
124
+            $headers = $cachedResponse[ 'headers' ];
125
+            $output  = $cachedResponse[ 'output' ];
126
+			$status = $cachedResponse[ 'status' ] ?? 200;
127
+            $reason  = $cachedResponse[ 'reason' ] ?? '';
128 128
 
129 129
             // Effacer tous les en-têtes par défaut
130 130
             foreach (array_keys($response->getHeaders()) as $key) {
Please login to merge, or discard this patch.