Passed
Push — main ( 99eb4f...cf0b02 )
by Thierry
04:07
created
jaxon-core/src/App/Metadata/MetadataCache.php 1 patch
Switch Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -28,60 +28,60 @@  discard block
 block discarded – undo
28 28
 
29 29
 class MetadataCache
30 30
 {
31
-    /**
31
+/**
32 32
      * @param string $sCacheDir
33 33
      */
34
-    public function __construct(private string $sCacheDir)
35
-    {}
34
+public function __construct(private string $sCacheDir)
35
+{}
36 36
 
37
-    /**
37
+/**
38 38
      * @param string $sClass
39 39
      *
40 40
      * @return string
41 41
      */
42
-    private function filepath(string $sClass): string
43
-    {
44
-        $sFilename = trim(str_replace(['\\', '.'], DIRECTORY_SEPARATOR,
45
-            strtolower($sClass)), DIRECTORY_SEPARATOR);
46
-        return rtrim($this->sCacheDir, "/\\") . DIRECTORY_SEPARATOR .
47
-            "metadata" . DIRECTORY_SEPARATOR . "{$sFilename}.php";
48
-    }
42
+private function filepath(string $sClass): string
43
+{
44
+$sFilename = trim(str_replace(['\\', '.'], DIRECTORY_SEPARATOR,
45
+strtolower($sClass)), DIRECTORY_SEPARATOR);
46
+return rtrim($this->sCacheDir, "/\\") . DIRECTORY_SEPARATOR .
47
+"metadata" . DIRECTORY_SEPARATOR . "{$sFilename}.php";
48
+}
49 49
 
50
-    /**
50
+/**
51 51
      * Generate the PHP code to create a metadata object.
52 52
      *
53 53
      * @return array
54 54
      */
55
-    private function encode(Metadata $xMetadata): array
55
+private function encode(Metadata $xMetadata): array
56
+{
57
+$sMetadataVar = '$xMetadata';
58
+$sDataVar = '$xData';
59
+$aCalls = ["$sMetadataVar = new " . Metadata::class . '();'];
60
+foreach($xMetadata->getAttributes() as $sType => $aValues)
61
+{
62
+foreach($aValues as $sMethod => $xData)
63
+{
64
+    $aCalls[] = "$sDataVar = {$sMetadataVar}->{$sType}('{$sMethod}');";
65
+    foreach($xData->encode($sDataVar) as $sCall)
56 66
     {
57
-        $sMetadataVar = '$xMetadata';
58
-        $sDataVar = '$xData';
59
-        $aCalls = ["$sMetadataVar = new " . Metadata::class . '();'];
60
-        foreach($xMetadata->getAttributes() as $sType => $aValues)
61
-        {
62
-            foreach($aValues as $sMethod => $xData)
63
-            {
64
-                $aCalls[] = "$sDataVar = {$sMetadataVar}->{$sType}('{$sMethod}');";
65
-                foreach($xData->encode($sDataVar) as $sCall)
66
-                {
67
-                    $aCalls[] = $sCall;
68
-                }
69
-            }
70
-        }
71
-        $aCalls[] = "return $sMetadataVar;";
72
-        return $aCalls;
67
+        $aCalls[] = $sCall;
73 68
     }
69
+}
70
+}
71
+$aCalls[] = "return $sMetadataVar;";
72
+return $aCalls;
73
+}
74 74
 
75
-    /**
75
+/**
76 76
      * @param string $sClass
77 77
      * @param Metadata $xMetadata
78 78
      *
79 79
      * @return void
80 80
      */
81
-    public function save(string $sClass, Metadata $xMetadata): void
82
-    {
83
-        $sDataCode = implode("\n    ", $this->encode($xMetadata));
84
-        $sPhpCode = <<<CODE
81
+public function save(string $sClass, Metadata $xMetadata): void
82
+{
83
+$sDataCode = implode("\n    ", $this->encode($xMetadata));
84
+$sPhpCode = <<<CODE
85 85
 <?php
86 86
 
87 87
 return function() {
@@ -89,21 +89,21 @@  discard block
 block discarded – undo
89 89
 };
90 90
 
91 91
 CODE;
92
-        // Recursively create the directories.
93
-        $sPath = $this->filepath($sClass);
94
-        @mkdir(dirname($sPath), 0755, true);
95
-        file_put_contents($sPath, $sPhpCode);
96
-    }
92
+// Recursively create the directories.
93
+$sPath = $this->filepath($sClass);
94
+@mkdir(dirname($sPath), 0755, true);
95
+file_put_contents($sPath, $sPhpCode);
96
+}
97 97
 
98
-    /**
98
+/**
99 99
      * @param string $sClass
100 100
      *
101 101
      * @return Metadata|null
102 102
      */
103
-    public function read(string $sClass): ?Metadata
104
-    {
105
-        $sPath = $this->filepath($sClass);
106
-        $fCreator = file_exists($sPath) ? require $sPath : null;
107
-        return $fCreator instanceof Closure ? $fCreator() : null;
108
-    }
103
+public function read(string $sClass): ?Metadata
104
+{
105
+$sPath = $this->filepath($sClass);
106
+$fCreator = file_exists($sPath) ? require $sPath : null;
107
+return $fCreator instanceof Closure ? $fCreator() : null;
108
+}
109 109
 }
Please login to merge, or discard this patch.