Olivier Massot 5 months ago
parent
commit
f1af704845

+ 3 - 3
src/Service/Twig/AssetsExtension.php

@@ -25,7 +25,7 @@ class AssetsExtension extends AbstractExtension
         string $projectDir,
         readonly private FileManager $fileManager,
     ) {
-        $this->publicDir = $projectDir . '/public';
+        $this->publicDir = $projectDir.'/public';
     }
 
     public function getFunctions(): array
@@ -68,7 +68,7 @@ class AssetsExtension extends AbstractExtension
 
     public function getAssetAbsolutePath(string $path): string
     {
-        return $this->publicDir . '/' . ltrim($path, '/');
+        return $this->publicDir.'/'.ltrim($path, '/');
     }
 
     public function getAssetBase64(string $path): string
@@ -82,6 +82,6 @@ class AssetsExtension extends AbstractExtension
         $imageData = file_get_contents($absolutePath);
         $mimeType = mime_content_type($absolutePath);
 
-        return 'data:' . $mimeType . ';base64,' . base64_encode($imageData);
+        return 'data:'.$mimeType.';base64,'.base64_encode($imageData);
     }
 }

+ 3 - 1
src/Service/Utils/DebugUtils.php

@@ -1,4 +1,5 @@
 <?php
+
 declare(strict_types=1);
 
 namespace App\Service\Utils;
@@ -7,7 +8,8 @@ use Path\Path;
 
 class DebugUtils
 {
-    public static function dumpToFile(mixed $var, bool $append = false): void {
+    public static function dumpToFile(mixed $var, bool $append = false): void
+    {
         $debugFile = (new Path(PathUtils::getProjectDir()))->append('var', 'dump.log');
 
         $datetime = date('Y-m-d H:i:s');

+ 6 - 6
tests/Unit/Service/Twig/AssetsExtensionTest.php

@@ -86,23 +86,23 @@ class AssetsExtensionTest extends TestCase
     public function testGetAssetAbsolutePath(): void
     {
         $assetsExtension = new AssetsExtension($this->projectDir, $this->fileManager);
-        $publicDir = $this->projectDir . '/public';
+        $publicDir = $this->projectDir.'/public';
 
         // Test with path starting with /
         $this->assertEquals(
-            $publicDir . '/images/logo.png',
+            $publicDir.'/images/logo.png',
             $assetsExtension->getAssetAbsolutePath('/images/logo.png')
         );
 
         // Test with path not starting with /
         $this->assertEquals(
-            $publicDir . '/images/logo.png',
+            $publicDir.'/images/logo.png',
             $assetsExtension->getAssetAbsolutePath('images/logo.png')
         );
 
         // Test with empty path
         $this->assertEquals(
-            $publicDir . '/',
+            $publicDir.'/',
             $assetsExtension->getAssetAbsolutePath('')
         );
     }
@@ -116,7 +116,7 @@ class AssetsExtensionTest extends TestCase
             ->getMock();
 
         // Set up the mock to return a specific path
-        $testFilePath = sys_get_temp_dir() . '/test_image.png';
+        $testFilePath = sys_get_temp_dir().'/test_image.png';
         $assetsExtension
             ->method('getAssetAbsolutePath')
             ->willReturn($testFilePath);
@@ -149,7 +149,7 @@ class AssetsExtensionTest extends TestCase
             ->getMock();
 
         // Set up the mock to return a non-existent file path
-        $nonExistentFilePath = sys_get_temp_dir() . '/non_existent_file.png';
+        $nonExistentFilePath = sys_get_temp_dir().'/non_existent_file.png';
         $assetsExtension->method('getAssetAbsolutePath')
             ->willReturn($nonExistentFilePath);