@@ -38,10 +38,10 @@ public function serveFilename(string $token, string $filename): Response
3838
3939 private function decryptPayload (string $ token ): array
4040 {
41- $ encoder = app (TokenEncoder::class);
42- $ cipher = $ encoder ->decode ($ token );
41+ $ encoder = app (TokenEncoder::class);
42+ $ cipher = $ encoder ->decode ($ token );
4343 $ encryptor = app (PayloadEncryptor::class);
44- $ json = $ encryptor ->decrypt ($ cipher );
44+ $ json = $ encryptor ->decrypt ($ cipher );
4545
4646 $ data = json_decode ($ json , true );
4747 if (! $ data || ! isset ($ data ['path ' ], $ data ['v ' ])) {
@@ -54,11 +54,11 @@ private function decryptPayload(string $token): array
5454 private function processAndDeliver (array $ data ): Response
5555 {
5656 $ sourceDisk = Storage::disk (config ('image-proxy.disks.source ' ));
57- $ cacheDisk = Storage::disk (config ('image-proxy.disks.cache ' ));
57+ $ cacheDisk = Storage::disk (config ('image-proxy.disks.cache ' ));
5858
5959 $ sourcePath = $ data ['path ' ];
6060
61- if (!$ sourceDisk ->exists ($ sourcePath )) {
61+ if (! $ sourceDisk ->exists ($ sourcePath )) {
6262 abort (404 );
6363 }
6464
@@ -69,23 +69,23 @@ private function processAndDeliver(array $data): Response
6969 }
7070
7171 $ strategyKey = $ data ['strategy ' ];
72- $ strategies = config ('image-proxy.manipulation_strategy ' );
72+ $ strategies = config ('image-proxy.manipulation_strategy ' );
7373
7474 if (! isset ($ strategies [$ strategyKey ])) {
7575 abort (500 , "Unknown image-proxy strategy: {$ strategyKey }" );
7676 }
7777
78- $ conf = $ strategies [$ strategyKey ];
79- $ class = $ conf ['class ' ];
80- $ default = $ conf ['params ' ] ?? [];
81- $ mergeParams = $ data ['mergeParams ' ] ?? [];
82- $ params = array_merge ($ default , $ mergeParams );
78+ $ conf = $ strategies [$ strategyKey ];
79+ $ class = $ conf ['class ' ];
80+ $ default = $ conf ['params ' ] ?? [];
81+ $ mergeParams = $ data ['mergeParams ' ] ?? [];
82+ $ params = array_merge ($ default , $ mergeParams );
8383
84- $ ext = pathinfo ($ sourcePath , PATHINFO_EXTENSION );
85- $ cacheHash = $ fileHash . '- ' . md5 (json_encode ($ params ));
86- $ cacheKey = $ cacheHash . '. ' . $ ext ;
84+ $ ext = pathinfo ($ sourcePath , PATHINFO_EXTENSION );
85+ $ cacheHash = $ fileHash. '- ' . md5 (json_encode ($ params ));
86+ $ cacheKey = $ cacheHash. '. ' . $ ext ;
8787
88- if (!$ cacheDisk ->exists ($ cacheKey )) {
88+ if (! $ cacheDisk ->exists ($ cacheKey )) {
8989 /** @var ImageManipulator $manipulator */
9090 $ manipulator = app ($ class );
9191 $ fileContent = $ manipulator ->manipulate ($ fileContent , $ params );
@@ -94,10 +94,11 @@ private function processAndDeliver(array $data): Response
9494 }
9595
9696 $ stream = $ cacheDisk ->readStream ($ cacheKey );
97- return new StreamedResponse (function () use ($ stream ) {
97+
98+ return new StreamedResponse (function () use ($ stream ) {
9899 fpassthru ($ stream );
99100 }, 200 , [
100- 'Content-Type ' => $ cacheDisk ->mimeType ($ cacheKey ),
101+ 'Content-Type ' => $ cacheDisk ->mimeType ($ cacheKey ),
101102 'Cache-Control ' => 'public, max-age=31536000, immutable ' ,
102103 ]);
103104 }
0 commit comments