Passed
Push — main ( 683317...8fa9e1 )
by Thierry
04:59
created
jaxon-core/src/Plugin/Request/CallableClass/ComponentOptions.php 1 patch
Switch Indentation   +169 added lines, -169 removed lines patch added patch discarded remove patch
@@ -34,224 +34,224 @@  discard block
 block discarded – undo
34 34
 
35 35
 class ComponentOptions
36 36
 {
37
-    /**
37
+/**
38 38
      * Check if the js code for this object must be generated
39 39
      *
40 40
      * @var bool
41 41
      */
42
-    private $bExcluded = false;
42
+private $bExcluded = false;
43 43
 
44
-    /**
44
+/**
45 45
      * The character to use as separator in javascript class names
46 46
      *
47 47
      * @var string
48 48
      */
49
-    private $sSeparator = '.';
49
+private $sSeparator = '.';
50 50
 
51
-    /**
51
+/**
52 52
      * A list of methods of the user registered callable object the library can export to javascript
53 53
      *
54 54
      * @var array
55 55
      */
56
-    private $aPublicMethods = [];
56
+private $aPublicMethods = [];
57 57
 
58
-    /**
58
+/**
59 59
      * The methods in the export attributes
60 60
      *
61 61
      * @var array
62 62
      */
63
-    private $aExportMethods = ['except' => []];
63
+private $aExportMethods = ['except' => []];
64 64
 
65
-    /**
65
+/**
66 66
      * A list of methods to call before processing the request
67 67
      *
68 68
      * @var array
69 69
      */
70
-    private $aBeforeMethods = [];
70
+private $aBeforeMethods = [];
71 71
 
72
-    /**
72
+/**
73 73
      * A list of methods to call after processing the request
74 74
      *
75 75
      * @var array
76 76
      */
77
-    private $aAfterMethods = [];
77
+private $aAfterMethods = [];
78 78
 
79
-    /**
79
+/**
80 80
      * The javascript class options
81 81
      *
82 82
      * @var array
83 83
      */
84
-    private $aJsOptions = [];
84
+private $aJsOptions = [];
85 85
 
86
-    /**
86
+/**
87 87
      * The DI options
88 88
      *
89 89
      * @var array
90 90
      */
91
-    private $aDiOptions = [];
91
+private $aDiOptions = [];
92 92
 
93
-    /**
93
+/**
94 94
      * The constructor
95 95
      *
96 96
      * @param array $aMethods
97 97
      * @param array $aOptions
98 98
      * @param Metadata|null $xMetadata
99 99
      */
100
-    public function __construct(array $aMethods, array $aOptions, Metadata|null $xMetadata)
101
-    {
102
-        $this->bExcluded = ($xMetadata?->isExcluded() ?? false) ||
103
-            (bool)($aOptions['excluded'] ?? false);
104
-
105
-        // Options from the config.
106
-        $sSeparator = $aOptions['separator'] ?? '.';
107
-        $this->sSeparator = $sSeparator === '_' ? '_' : '.';
108
-        $this->addProtectedMethods($aOptions['protected'] ?? []);
109
-        foreach($aOptions['functions'] ?? [] as $sNames => $aFunctionOptions)
110
-        {
111
-            // Names are in a comma-separated list.
112
-            $aFunctionNames = explode(',', $sNames);
113
-            foreach($aFunctionNames as $sFunctionName)
114
-            {
115
-                $this->addFunctionOptions($sFunctionName, $aFunctionOptions);
116
-            }
117
-        }
100
+public function __construct(array $aMethods, array $aOptions, Metadata|null $xMetadata)
101
+{
102
+$this->bExcluded = ($xMetadata?->isExcluded() ?? false) ||
103
+(bool)($aOptions['excluded'] ?? false);
104
+
105
+// Options from the config.
106
+$sSeparator = $aOptions['separator'] ?? '.';
107
+$this->sSeparator = $sSeparator === '_' ? '_' : '.';
108
+$this->addProtectedMethods($aOptions['protected'] ?? []);
109
+foreach($aOptions['functions'] ?? [] as $sNames => $aFunctionOptions)
110
+{
111
+// Names are in a comma-separated list.
112
+$aFunctionNames = explode(',', $sNames);
113
+foreach($aFunctionNames as $sFunctionName)
114
+{
115
+    $this->addFunctionOptions($sFunctionName, $aFunctionOptions);
116
+}
117
+}
118 118
 
119
-        // Options from the attributes or annotations.
120
-        if($xMetadata !== null)
121
-        {
122
-            $this->readMetadataOptions($xMetadata);
123
-        }
119
+// Options from the attributes or annotations.
120
+if($xMetadata !== null)
121
+{
122
+$this->readMetadataOptions($xMetadata);
123
+}
124 124
 
125
-        $this->aPublicMethods = $this->filterPublicMethods($aMethods);
126
-    }
125
+$this->aPublicMethods = $this->filterPublicMethods($aMethods);
126
+}
127 127
 
128
-    /**
128
+/**
129 129
      * @param array|string $xMethods
130 130
      *
131 131
      * @return void
132 132
      */
133
-    private function addProtectedMethods(array|string $xMethods): void
134
-    {
135
-        $this->aExportMethods['except'] = array_merge($this->aExportMethods['except'],
136
-            !is_array($xMethods) ? [trim((string)$xMethods)] :
137
-            array_map(fn($sMethod) => trim((string)$sMethod), $xMethods));
138
-    }
133
+private function addProtectedMethods(array|string $xMethods): void
134
+{
135
+$this->aExportMethods['except'] = array_merge($this->aExportMethods['except'],
136
+!is_array($xMethods) ? [trim((string)$xMethods)] :
137
+array_map(fn($sMethod) => trim((string)$sMethod), $xMethods));
138
+}
139 139
 
140
-    /**
140
+/**
141 141
      * @param Metadata $xMetadata
142 142
      *
143 143
      * @return void
144 144
      */
145
-    private function readMetadataOptions(Metadata $xMetadata): void
146
-    {
147
-        // Excluded methods must be merged with the existing ones.
148
-        $aExportMethods = $xMetadata->getExportMethods();
149
-        $aExportMethods['except'] = array_unique(array_merge(
150
-            $aExportMethods['except'] ?? [], $this->aExportMethods['except']));
151
-        $this->aExportMethods = $aExportMethods;
152
-        foreach($xMetadata->getProperties() as $sFunctionName => $aFunctionOptions)
153
-        {
154
-            $this->addFunctionOptions($sFunctionName, $aFunctionOptions);
155
-        }
156
-    }
145
+private function readMetadataOptions(Metadata $xMetadata): void
146
+{
147
+// Excluded methods must be merged with the existing ones.
148
+$aExportMethods = $xMetadata->getExportMethods();
149
+$aExportMethods['except'] = array_unique(array_merge(
150
+$aExportMethods['except'] ?? [], $this->aExportMethods['except']));
151
+$this->aExportMethods = $aExportMethods;
152
+foreach($xMetadata->getProperties() as $sFunctionName => $aFunctionOptions)
153
+{
154
+$this->addFunctionOptions($sFunctionName, $aFunctionOptions);
155
+}
156
+}
157 157
 
158
-    /**
158
+/**
159 159
      * @param array $aMethods
160 160
      *
161 161
      * @return array
162 162
      */
163
-    private function filterPublicMethods(array $aMethods): array
164
-    {
165
-        if($this->bExcluded || in_array('*', $this->aExportMethods['except']))
166
-        {
167
-            return [];
168
-        }
163
+private function filterPublicMethods(array $aMethods): array
164
+{
165
+if($this->bExcluded || in_array('*', $this->aExportMethods['except']))
166
+{
167
+return [];
168
+}
169 169
 
170
-        $aBaseMethods = $aMethods[1];
171
-        $aNoMethods = $aMethods[2];
172
-        $aMethods = $aMethods[0];
173
-        if(isset($this->aExportMethods['only']))
174
-        {
175
-            $aMethods = array_intersect($aMethods, $this->aExportMethods['only']);
176
-        }
177
-        $aMethods = array_diff($aMethods, $this->aExportMethods['except']);
178
-        if(count($aBaseMethods) > 0 && isset($this->aExportMethods['base']))
179
-        {
180
-            $aBaseMethods = array_diff($aBaseMethods, $this->aExportMethods['base']);
181
-        }
170
+$aBaseMethods = $aMethods[1];
171
+$aNoMethods = $aMethods[2];
172
+$aMethods = $aMethods[0];
173
+if(isset($this->aExportMethods['only']))
174
+{
175
+$aMethods = array_intersect($aMethods, $this->aExportMethods['only']);
176
+}
177
+$aMethods = array_diff($aMethods, $this->aExportMethods['except']);
178
+if(count($aBaseMethods) > 0 && isset($this->aExportMethods['base']))
179
+{
180
+$aBaseMethods = array_diff($aBaseMethods, $this->aExportMethods['base']);
181
+}
182 182
 
183
-        return array_values(array_diff($aMethods, $aBaseMethods, $aNoMethods));
184
-    }
183
+return array_values(array_diff($aMethods, $aBaseMethods, $aNoMethods));
184
+}
185 185
 
186
-    /**
186
+/**
187 187
      * @return array
188 188
      */
189
-    public function getPublicMethods(): array
190
-    {
191
-        return $this->aPublicMethods;
192
-    }
189
+public function getPublicMethods(): array
190
+{
191
+return $this->aPublicMethods;
192
+}
193 193
 
194
-    /**
194
+/**
195 195
      * @param string $sMethodName
196 196
      *
197 197
      * @return bool
198 198
      */
199
-    public function isPublicMethod(string $sMethodName): bool
200
-    {
201
-        return in_array($sMethodName, $this->aPublicMethods);
202
-    }
199
+public function isPublicMethod(string $sMethodName): bool
200
+{
201
+return in_array($sMethodName, $this->aPublicMethods);
202
+}
203 203
 
204
-    /**
204
+/**
205 205
      * Check if the js code for this object must be generated
206 206
      *
207 207
      * @return bool
208 208
      */
209
-    public function excluded(): bool
210
-    {
211
-        return $this->bExcluded;
212
-    }
209
+public function excluded(): bool
210
+{
211
+return $this->bExcluded;
212
+}
213 213
 
214
-    /**
214
+/**
215 215
      * @return string
216 216
      */
217
-    public function separator(): string
218
-    {
219
-        return $this->sSeparator;
220
-    }
217
+public function separator(): string
218
+{
219
+return $this->sSeparator;
220
+}
221 221
 
222
-    /**
222
+/**
223 223
      * @return array
224 224
      */
225
-    public function beforeMethods(): array
226
-    {
227
-        return $this->aBeforeMethods;
228
-    }
225
+public function beforeMethods(): array
226
+{
227
+return $this->aBeforeMethods;
228
+}
229 229
 
230
-    /**
230
+/**
231 231
      * @return array
232 232
      */
233
-    public function afterMethods(): array
234
-    {
235
-        return $this->aAfterMethods;
236
-    }
233
+public function afterMethods(): array
234
+{
235
+return $this->aAfterMethods;
236
+}
237 237
 
238
-    /**
238
+/**
239 239
      * @return array
240 240
      */
241
-    public function diOptions(): array
242
-    {
243
-        return $this->aDiOptions;
244
-    }
241
+public function diOptions(): array
242
+{
243
+return $this->aDiOptions;
244
+}
245 245
 
246
-    /**
246
+/**
247 247
      * @return array
248 248
      */
249
-    public function jsOptions(): array
250
-    {
251
-        return $this->aJsOptions;
252
-    }
249
+public function jsOptions(): array
250
+{
251
+return $this->aJsOptions;
252
+}
253 253
 
254
-    /**
254
+/**
255 255
      * Set hook methods
256 256
      *
257 257
      * @param array $aHookMethods    The array of hook methods
@@ -259,36 +259,36 @@  discard block
 block discarded – undo
259 259
      *
260 260
      * @return void
261 261
      */
262
-    private function setHookMethods(array &$aHookMethods, $xValue): void
263
-    {
264
-        foreach($xValue as $sCalledMethod => $xMethodToCall)
265
-        {
266
-            if(!isset($aHookMethods[$sCalledMethod]))
267
-            {
268
-                $aHookMethods[$sCalledMethod] = [];
269
-            }
270
-            if(is_array($xMethodToCall))
271
-            {
272
-                $aHookMethods[$sCalledMethod] =
273
-                    array_merge($aHookMethods[$sCalledMethod], $xMethodToCall);
274
-                continue;
275
-            }
276
-            if(is_string($xMethodToCall))
277
-            {
278
-                $aHookMethods[$sCalledMethod][] = $xMethodToCall;
279
-            }
280
-        }
281
-    }
262
+private function setHookMethods(array &$aHookMethods, $xValue): void
263
+{
264
+foreach($xValue as $sCalledMethod => $xMethodToCall)
265
+{
266
+if(!isset($aHookMethods[$sCalledMethod]))
267
+{
268
+    $aHookMethods[$sCalledMethod] = [];
269
+}
270
+if(is_array($xMethodToCall))
271
+{
272
+    $aHookMethods[$sCalledMethod] =
273
+        array_merge($aHookMethods[$sCalledMethod], $xMethodToCall);
274
+    continue;
275
+}
276
+if(is_string($xMethodToCall))
277
+{
278
+    $aHookMethods[$sCalledMethod][] = $xMethodToCall;
279
+}
280
+}
281
+}
282 282
 
283
-    /**
283
+/**
284 284
      * @param array $aDiOptions
285 285
      */
286
-    private function addDiOption(array $aDiOptions): void
287
-    {
288
-        $this->aDiOptions = array_merge($this->aDiOptions, $aDiOptions);
289
-    }
286
+private function addDiOption(array $aDiOptions): void
287
+{
288
+$this->aDiOptions = array_merge($this->aDiOptions, $aDiOptions);
289
+}
290 290
 
291
-    /**
291
+/**
292 292
      * Set configuration options / call options for each method
293 293
      *
294 294
      * @param string $sName    The name of the configuration option
@@ -296,25 +296,25 @@  discard block
 block discarded – undo
296 296
      *
297 297
      * @return void
298 298
      */
299
-    private function addOption(string $sName, $xValue): void
300
-    {
301
-        switch($sName)
302
-        {
303
-        // Set the methods to call before processing the request
304
-        case '__before':
305
-            $this->setHookMethods($this->aBeforeMethods, $xValue);
306
-            break;
307
-        // Set the methods to call after processing the request
308
-        case '__after':
309
-            $this->setHookMethods($this->aAfterMethods, $xValue);
310
-            break;
311
-        // Set the attributes to inject in the callable object
312
-        case '__di':
313
-            $this->addDiOption($xValue);
314
-            break;
315
-        default:
316
-            break;
317
-        }
299
+private function addOption(string $sName, $xValue): void
300
+{
301
+switch($sName)
302
+{
303
+// Set the methods to call before processing the request
304
+case '__before':
305
+$this->setHookMethods($this->aBeforeMethods, $xValue);
306
+break;
307
+// Set the methods to call after processing the request
308
+case '__after':
309
+$this->setHookMethods($this->aAfterMethods, $xValue);
310
+break;
311
+// Set the attributes to inject in the callable object
312
+case '__di':
313
+$this->addDiOption($xValue);
314
+break;
315
+default:
316
+break;
317
+}
318 318
     }
319 319
 
320 320
     /**
Please login to merge, or discard this patch.
jaxon-annotations/src/AnnotationReader.php 1 patch
Switch Indentation   +152 added lines, -152 removed lines patch added patch discarded remove patch
@@ -37,207 +37,207 @@
 block discarded – undo
37 37
 
38 38
 class AnnotationReader implements MetadataReaderInterface
39 39
 {
40
-    /**
40
+/**
41 41
      * @var AnnotationManager
42 42
      */
43
-    protected $xManager;
43
+protected $xManager;
44 44
 
45
-    /**
45
+/**
46 46
      * @var Metadata
47 47
      */
48
-    protected $xMetadata;
48
+protected $xMetadata;
49 49
 
50
-    /**
50
+/**
51 51
      * Properties types, read from the "var" annotations.
52 52
      *
53 53
      * @var array
54 54
      */
55
-    protected $aPropTypes;
55
+protected $aPropTypes;
56 56
 
57
-    /**
57
+/**
58 58
      * The type of the class member being currently processed.
59 59
      *
60 60
      * @var string
61 61
      */
62
-    protected $sCurrMemberType;
62
+protected $sCurrMemberType;
63 63
 
64
-    /**
64
+/**
65 65
      * The constructor
66 66
      *
67 67
      * @param AnnotationManager $xManager
68 68
      */
69
-    public function __construct(AnnotationManager $xManager)
70
-    {
71
-        $this->xManager = $xManager;
72
-        $this->xManager->registry['upload'] = UploadAnnotation::class;
73
-        $this->xManager->registry['databag'] = DatabagAnnotation::class;
74
-        $this->xManager->registry['exclude'] = ExcludeAnnotation::class;
75
-        $this->xManager->registry['export'] = ExportAnnotation::class;
76
-        $this->xManager->registry['before'] = BeforeAnnotation::class;
77
-        $this->xManager->registry['after'] = AfterAnnotation::class;
78
-        $this->xManager->registry['di'] = ContainerAnnotation::class;
79
-        $this->xManager->registry['callback'] = CallbackAnnotation::class;
80
-        // Missing standard annotations.
81
-        // We need to define this, otherwise they throw an exception, and make the whole processing fail.
82
-        $this->xManager->registry['const'] = false;
83
-        $this->xManager->registry['inheritDoc'] = false;
84
-        $this->xManager->registry['template'] = false;
85
-        $this->xManager->registry['param-closure-this'] = false;
86
-    }
69
+public function __construct(AnnotationManager $xManager)
70
+{
71
+$this->xManager = $xManager;
72
+$this->xManager->registry['upload'] = UploadAnnotation::class;
73
+$this->xManager->registry['databag'] = DatabagAnnotation::class;
74
+$this->xManager->registry['exclude'] = ExcludeAnnotation::class;
75
+$this->xManager->registry['export'] = ExportAnnotation::class;
76
+$this->xManager->registry['before'] = BeforeAnnotation::class;
77
+$this->xManager->registry['after'] = AfterAnnotation::class;
78
+$this->xManager->registry['di'] = ContainerAnnotation::class;
79
+$this->xManager->registry['callback'] = CallbackAnnotation::class;
80
+// Missing standard annotations.
81
+// We need to define this, otherwise they throw an exception, and make the whole processing fail.
82
+$this->xManager->registry['const'] = false;
83
+$this->xManager->registry['inheritDoc'] = false;
84
+$this->xManager->registry['template'] = false;
85
+$this->xManager->registry['param-closure-this'] = false;
86
+}
87 87
 
88
-    /**
88
+/**
89 89
      * @return array
90 90
      */
91
-    public function getPropTypes(): array
92
-    {
93
-        return $this->aPropTypes;
94
-    }
91
+public function getPropTypes(): array
92
+{
93
+return $this->aPropTypes;
94
+}
95 95
 
96
-    /**
96
+/**
97 97
      * @return bool
98 98
      */
99
-    public function annotationIsOnProperty(): bool
100
-    {
101
-        return $this->sCurrMemberType === AnnotationManager::MEMBER_PROPERTY;
102
-    }
99
+public function annotationIsOnProperty(): bool
100
+{
101
+return $this->sCurrMemberType === AnnotationManager::MEMBER_PROPERTY;
102
+}
103 103
 
104
-    /**
104
+/**
105 105
      * @param string $sClass
106 106
      *
107 107
      * @return void
108 108
      * @throws AnnotationException
109 109
      */
110
-    private function readClassAnnotations(string $sClass): void
111
-    {
112
-        // Only keep the annotations declared in this package.
113
-        /** @var array<AbstractAnnotation> */
114
-        $aAnnotations = array_filter(
115
-            $this->xManager->getClassAnnotations($sClass),
116
-            fn($xAnnotation) => is_a($xAnnotation, AbstractAnnotation::class)
117
-        );
118
-        // First check if the class is excluded.
119
-        foreach($aAnnotations as $xAnnotation)
120
-        {
121
-            if(is_a($xAnnotation, ExcludeAnnotation::class))
122
-            {
123
-                $xAnnotation->saveValue($this->xMetadata);
124
-            }
125
-        }
126
-        if($this->xMetadata->isExcluded())
127
-        {
128
-            return;
129
-        }
130
-
131
-        foreach($aAnnotations as $xAnnotation)
132
-        {
133
-            if(!is_a($xAnnotation, ExcludeAnnotation::class))
134
-            {
135
-                $xAnnotation->saveValue($this->xMetadata);
136
-            }
137
-        }
138
-    }
110
+private function readClassAnnotations(string $sClass): void
111
+{
112
+// Only keep the annotations declared in this package.
113
+/** @var array<AbstractAnnotation> */
114
+$aAnnotations = array_filter(
115
+$this->xManager->getClassAnnotations($sClass),
116
+fn($xAnnotation) => is_a($xAnnotation, AbstractAnnotation::class)
117
+);
118
+// First check if the class is excluded.
119
+foreach($aAnnotations as $xAnnotation)
120
+{
121
+if(is_a($xAnnotation, ExcludeAnnotation::class))
122
+{
123
+    $xAnnotation->saveValue($this->xMetadata);
124
+}
125
+}
126
+if($this->xMetadata->isExcluded())
127
+{
128
+return;
129
+}
139 130
 
140
-    /**
131
+foreach($aAnnotations as $xAnnotation)
132
+{
133
+if(!is_a($xAnnotation, ExcludeAnnotation::class))
134
+{
135
+    $xAnnotation->saveValue($this->xMetadata);
136
+}
137
+}
138
+}
139
+
140
+/**
141 141
      * @param string $sClass
142 142
      * @param string $sProperty
143 143
      *
144 144
      * @return void
145 145
      * @throws AnnotationException
146 146
      */
147
-    private function readPropertyAnnotations(string $sClass, string $sProperty): void
147
+private function readPropertyAnnotations(string $sClass, string $sProperty): void
148
+{
149
+/** @var array<ContainerAnnotation> */
150
+// Only keep the annotations declared in this package.
151
+$aAnnotations = array_filter(
152
+$this->xManager->getPropertyAnnotations($sClass, $sProperty),
153
+function($xAnnotation) use($sProperty) {
154
+    // Save the property type
155
+    if(is_a($xAnnotation, VarAnnotation::class))
148 156
     {
149
-        /** @var array<ContainerAnnotation> */
150
-        // Only keep the annotations declared in this package.
151
-        $aAnnotations = array_filter(
152
-            $this->xManager->getPropertyAnnotations($sClass, $sProperty),
153
-            function($xAnnotation) use($sProperty) {
154
-                // Save the property type
155
-                if(is_a($xAnnotation, VarAnnotation::class))
156
-                {
157
-                    $this->aPropTypes[$sProperty] = $xAnnotation->type;
158
-                }
159
-                // Only container annotations are allowed on properties
160
-                return is_a($xAnnotation, ContainerAnnotation::class);
161
-            }
162
-        );
163
-        if(count($aAnnotations) > 1)
164
-        {
165
-            throw new AnnotationException('Only one @di annotation is allowed on a property');
166
-        }
167
-
168
-        foreach($aAnnotations as $xAnnotation)
169
-        {
170
-            $xAnnotation->setAttr($sProperty);
171
-            $xAnnotation->saveValue($this->xMetadata);
172
-        }
157
+        $this->aPropTypes[$sProperty] = $xAnnotation->type;
173 158
     }
159
+    // Only container annotations are allowed on properties
160
+    return is_a($xAnnotation, ContainerAnnotation::class);
161
+}
162
+);
163
+if(count($aAnnotations) > 1)
164
+{
165
+throw new AnnotationException('Only one @di annotation is allowed on a property');
166
+}
167
+
168
+foreach($aAnnotations as $xAnnotation)
169
+{
170
+$xAnnotation->setAttr($sProperty);
171
+$xAnnotation->saveValue($this->xMetadata);
172
+}
173
+}
174 174
 
175
-    /**
175
+/**
176 176
      * @param string $sClass
177 177
      * @param string $sMethod
178 178
      *
179 179
      * @return void
180 180
      * @throws AnnotationException
181 181
      */
182
-    private function readMethodAnnotations(string $sClass, string $sMethod): void
183
-    {
184
-        // Only keep the annotations declared in this package.
185
-        /** @var array<AbstractAnnotation> */
186
-        $aAnnotations = array_filter(
187
-            $this->xManager->getMethodAnnotations($sClass, $sMethod),
188
-            fn($xAnnotation) => is_a($xAnnotation, AbstractAnnotation::class)
189
-        );
190
-        foreach($aAnnotations as $xAnnotation)
191
-        {
192
-            $xAnnotation->saveValue($this->xMetadata, $sMethod);
193
-        }
194
-    }
182
+private function readMethodAnnotations(string $sClass, string $sMethod): void
183
+{
184
+// Only keep the annotations declared in this package.
185
+/** @var array<AbstractAnnotation> */
186
+$aAnnotations = array_filter(
187
+$this->xManager->getMethodAnnotations($sClass, $sMethod),
188
+fn($xAnnotation) => is_a($xAnnotation, AbstractAnnotation::class)
189
+);
190
+foreach($aAnnotations as $xAnnotation)
191
+{
192
+$xAnnotation->saveValue($this->xMetadata, $sMethod);
193
+}
194
+}
195 195
 
196
-    /**
196
+/**
197 197
      * @throws SetupException
198 198
      */
199
-    public function getAttributes(InputData $xInput): Metadata
200
-    {
201
-        ContainerAnnotation::$xReader = $this;
202
-        $this->aPropTypes = [];
203
-        $this->xMetadata = new Metadata();
204
-        $sClass = $xInput->getReflectionClass()->getName();
205
-
206
-        try
207
-        {
208
-            // Processing class annotations
209
-            $this->sCurrMemberType = AnnotationManager::MEMBER_CLASS;
210
-
211
-            $this->readClassAnnotations($sClass);
212
-
213
-            // Processing properties annotations
214
-            $this->sCurrMemberType = AnnotationManager::MEMBER_PROPERTY;
215
-
216
-            // Properties annotations
217
-            foreach($xInput->getProperties() as $sProperty)
218
-            {
219
-                $this->readPropertyAnnotations($sClass, $sProperty);
220
-            }
221
-
222
-            // The methods annotations are not taken for excluded classes.
223
-            if($this->xMetadata->isExcluded())
224
-            {
225
-                return $this->xMetadata;
226
-            }
227
-
228
-            // Processing methods annotations
229
-            $this->sCurrMemberType = AnnotationManager::MEMBER_METHOD;
230
-
231
-            foreach($xInput->getMethods() as $sMethod)
232
-            {
233
-                $this->readMethodAnnotations($sClass, $sMethod);
234
-            }
235
-
236
-            return $this->xMetadata;
237
-        }
238
-        catch(AnnotationException $e)
239
-        {
240
-            throw new SetupException($e->getMessage());
241
-        }
242
-    }
199
+public function getAttributes(InputData $xInput): Metadata
200
+{
201
+ContainerAnnotation::$xReader = $this;
202
+$this->aPropTypes = [];
203
+$this->xMetadata = new Metadata();
204
+$sClass = $xInput->getReflectionClass()->getName();
205
+
206
+try
207
+{
208
+// Processing class annotations
209
+$this->sCurrMemberType = AnnotationManager::MEMBER_CLASS;
210
+
211
+$this->readClassAnnotations($sClass);
212
+
213
+// Processing properties annotations
214
+$this->sCurrMemberType = AnnotationManager::MEMBER_PROPERTY;
215
+
216
+// Properties annotations
217
+foreach($xInput->getProperties() as $sProperty)
218
+{
219
+    $this->readPropertyAnnotations($sClass, $sProperty);
220
+}
221
+
222
+// The methods annotations are not taken for excluded classes.
223
+if($this->xMetadata->isExcluded())
224
+{
225
+    return $this->xMetadata;
226
+}
227
+
228
+// Processing methods annotations
229
+$this->sCurrMemberType = AnnotationManager::MEMBER_METHOD;
230
+
231
+foreach($xInput->getMethods() as $sMethod)
232
+{
233
+    $this->readMethodAnnotations($sClass, $sMethod);
234
+}
235
+
236
+return $this->xMetadata;
237
+}
238
+catch(AnnotationException $e)
239
+{
240
+throw new SetupException($e->getMessage());
241
+}
242
+}
243 243
 }
Please login to merge, or discard this patch.
jaxon-core/src/Di/Traits/ComponentTrait.php 1 patch
Switch Indentation   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -241,83 +241,83 @@
 block discarded – undo
241 241
                 $this->aComponentPublicMethods['node'],
242 242
             $xReflectionClass->isSubclassOf(FuncComponent::class) =>
243 243
                 $this->aComponentPublicMethods['func'],
244
-            default => [[], []],
245
-        };
244
+default => [[], []],
245
+};
246 246
 
247
-        return [$aMethods, ...$aBaseMethods];
248
-    }
247
+return [$aMethods, ...$aBaseMethods];
248
+}
249 249
 
250
-    /**
250
+/**
251 251
      * @param ReflectionClass $xReflectionClass
252 252
      * @param array $aMethods
253 253
      * @param array $aOptions
254 254
      *
255 255
      * @return Metadata|null
256 256
      */
257
-    private function getComponentMetadata(ReflectionClass $xReflectionClass,
258
-        array $aMethods, array $aOptions): Metadata|null
259
-    {
260
-        /** @var Config|null */
261
-        $xPackageConfig = $aOptions['config'] ?? null;
262
-        if($xPackageConfig === null || (bool)($aOptions['excluded'] ?? false))
263
-        {
264
-            return null;
265
-        }
266
-        $sMetadataFormat = $xPackageConfig->getOption('metadata.format');
267
-        if(!in_array($sMetadataFormat, ['attributes', 'annotations']))
268
-        {
269
-            return null;
270
-        }
257
+private function getComponentMetadata(ReflectionClass $xReflectionClass,
258
+array $aMethods, array $aOptions): Metadata|null
259
+{
260
+/** @var Config|null */
261
+$xPackageConfig = $aOptions['config'] ?? null;
262
+if($xPackageConfig === null || (bool)($aOptions['excluded'] ?? false))
263
+{
264
+return null;
265
+}
266
+$sMetadataFormat = $xPackageConfig->getOption('metadata.format');
267
+if(!in_array($sMetadataFormat, ['attributes', 'annotations']))
268
+{
269
+return null;
270
+}
271 271
 
272
-        // Try to get the class metadata from the cache.
273
-        $di = $this->cn();
274
-        $xMetadata = null;
275
-        $xMetadataCache = null;
276
-        $xConfig = $di->config();
277
-        if($xConfig->getAppOption('metadata.cache.enabled', false))
278
-        {
279
-            if(!$di->h('jaxon_metadata_cache_dir'))
280
-            {
281
-                $sCacheDir = $xConfig->getAppOption('metadata.cache.dir');
282
-                $di->val('jaxon_metadata_cache_dir', $sCacheDir);
283
-            }
284
-            $xMetadataCache = $di->getMetadataCache();
285
-            $xMetadata = $xMetadataCache->read($xReflectionClass->getName());
286
-            if($xMetadata !== null)
287
-            {
288
-                return $xMetadata;
289
-            }
290
-        }
272
+// Try to get the class metadata from the cache.
273
+$di = $this->cn();
274
+$xMetadata = null;
275
+$xMetadataCache = null;
276
+$xConfig = $di->config();
277
+if($xConfig->getAppOption('metadata.cache.enabled', false))
278
+{
279
+if(!$di->h('jaxon_metadata_cache_dir'))
280
+{
281
+    $sCacheDir = $xConfig->getAppOption('metadata.cache.dir');
282
+    $di->val('jaxon_metadata_cache_dir', $sCacheDir);
283
+}
284
+$xMetadataCache = $di->getMetadataCache();
285
+$xMetadata = $xMetadataCache->read($xReflectionClass->getName());
286
+if($xMetadata !== null)
287
+{
288
+    return $xMetadata;
289
+}
290
+}
291 291
 
292
-        $aProperties = array_map(fn($xProperty) => $xProperty->getName(),
293
-            $xReflectionClass->getProperties(ReflectionProperty::IS_PUBLIC |
294
-                ReflectionProperty::IS_PROTECTED));
292
+$aProperties = array_map(fn($xProperty) => $xProperty->getName(),
293
+$xReflectionClass->getProperties(ReflectionProperty::IS_PUBLIC |
294
+    ReflectionProperty::IS_PROTECTED));
295 295
 
296
-        $xMetadataReader = $di->getMetadataReader($sMetadataFormat);
297
-        $xInput = new InputData($xReflectionClass, $aMethods, $aProperties);
298
-        $xMetadata = $xMetadataReader->getAttributes($xInput);
296
+$xMetadataReader = $di->getMetadataReader($sMetadataFormat);
297
+$xInput = new InputData($xReflectionClass, $aMethods, $aProperties);
298
+$xMetadata = $xMetadataReader->getAttributes($xInput);
299 299
 
300
-        // Try to save the metadata in the cache
301
-        if($xMetadataCache !== null)
302
-        {
303
-            $xMetadataCache->save($xReflectionClass->getName(), $xMetadata);
304
-        }
300
+// Try to save the metadata in the cache
301
+if($xMetadataCache !== null)
302
+{
303
+$xMetadataCache->save($xReflectionClass->getName(), $xMetadata);
304
+}
305 305
 
306
-        return $xMetadata;
307
-    }
306
+return $xMetadata;
307
+}
308 308
 
309
-    /**
309
+/**
310 310
      * @param ReflectionClass $xReflectionClass
311 311
      * @param array $aOptions
312 312
      *
313 313
      * @return ComponentOptions
314 314
      */
315
-    public function getComponentOptions(ReflectionClass $xReflectionClass,
316
-        array $aOptions): ComponentOptions
317
-    {
318
-        $aMethods = $this->getPublicMethods($xReflectionClass);
319
-        $xMetadata = $this->getComponentMetadata($xReflectionClass, $aMethods[0], $aOptions);
315
+public function getComponentOptions(ReflectionClass $xReflectionClass,
316
+array $aOptions): ComponentOptions
317
+{
318
+$aMethods = $this->getPublicMethods($xReflectionClass);
319
+$xMetadata = $this->getComponentMetadata($xReflectionClass, $aMethods[0], $aOptions);
320 320
 
321
-        return new ComponentOptions($aMethods, $aOptions, $xMetadata);
322
-    }
321
+return new ComponentOptions($aMethods, $aOptions, $xMetadata);
322
+}
323 323
 }
Please login to merge, or discard this patch.
jaxon-core/src/Di/Traits/PluginTrait.php 1 patch
Switch Indentation   +139 added lines, -139 removed lines patch added patch discarded remove patch
@@ -35,154 +35,154 @@  discard block
 block discarded – undo
35 35
 
36 36
 trait PluginTrait
37 37
 {
38
-    /**
38
+/**
39 39
      * Register the values into the container
40 40
      *
41 41
      * @return void
42 42
      */
43
-    private function registerPlugins(): void
44
-    {
45
-        // Plugin manager
46
-        $this->set(PluginManager::class, function($di) {
47
-            $xPluginManager = new PluginManager($di->g(Container::class),
48
-                $di->g(CodeGenerator::class), $di->g(Translator::class));
49
-            // Register the Jaxon request and response plugins
50
-            $xPluginManager->registerPlugins();
51
-            return $xPluginManager;
52
-        });
53
-        // Package manager
54
-        $this->set(PackageManager::class, function($di) {
55
-            return new PackageManager($di->g(Container::class), $di->g(Translator::class),
56
-                $di->g(PluginManager::class), $di->g(ConfigManager::class),
57
-                $di->g(CodeGenerator::class), $di->g(ViewRenderer::class),
58
-                $di->g(CallbackManager::class), $di->g(ComponentRegistry::class));
59
-        });
60
-        // Code Generation
61
-        $this->set(MinifierInterface::class, function() {
62
-            return new class extends FileMinifier implements MinifierInterface
63
-            {};
64
-        });
65
-        $this->set(AssetManager::class, function($di) {
66
-            return new AssetManager($di->g(ConfigManager::class),
67
-                $di->g(MinifierInterface::class));
68
-        });
69
-        $this->set(CodeGenerator::class, function($di) {
70
-            return new CodeGenerator(Jaxon::VERSION, $di->g(Container::class),
71
-                $di->g(TemplateEngine::class));
72
-        });
73
-        $this->set(ConfigScriptGenerator::class, function($di) {
74
-            return new ConfigScriptGenerator($di->g(ParameterReader::class),
75
-                $di->g(TemplateEngine::class), $di->g(ConfigManager::class));
76
-        });
77
-        $this->set(ReadyScriptGenerator::class, function($di) {
78
-            return new ReadyScriptGenerator();
79
-        });
80
-
81
-        // Script response plugin
82
-        $this->set(ScriptPlugin::class, function($di) {
83
-            return new ScriptPlugin($di->g(CallFactory::class));
84
-        });
85
-        // Databag response plugin
86
-        $this->set(DatabagPlugin::class, function($di) {
87
-            return new DatabagPlugin($di->g(Container::class));
88
-        });
89
-        // Dialog response plugin
90
-        $this->set(DialogPlugin::class, function($di) {
91
-            return new DialogPlugin($di->g(DialogCommand::class));
92
-        });
93
-        // Paginator response plugin
94
-        $this->set(PaginatorPlugin::class, function($di) {
95
-            return new PaginatorPlugin($di->g(RendererInterface::class));
96
-        });
97
-    }
98
-
99
-    /**
43
+private function registerPlugins(): void
44
+{
45
+// Plugin manager
46
+$this->set(PluginManager::class, function($di) {
47
+$xPluginManager = new PluginManager($di->g(Container::class),
48
+    $di->g(CodeGenerator::class), $di->g(Translator::class));
49
+// Register the Jaxon request and response plugins
50
+$xPluginManager->registerPlugins();
51
+return $xPluginManager;
52
+});
53
+// Package manager
54
+$this->set(PackageManager::class, function($di) {
55
+return new PackageManager($di->g(Container::class), $di->g(Translator::class),
56
+    $di->g(PluginManager::class), $di->g(ConfigManager::class),
57
+    $di->g(CodeGenerator::class), $di->g(ViewRenderer::class),
58
+    $di->g(CallbackManager::class), $di->g(ComponentRegistry::class));
59
+});
60
+// Code Generation
61
+$this->set(MinifierInterface::class, function() {
62
+return new class extends FileMinifier implements MinifierInterface
63
+{};
64
+});
65
+$this->set(AssetManager::class, function($di) {
66
+return new AssetManager($di->g(ConfigManager::class),
67
+    $di->g(MinifierInterface::class));
68
+});
69
+$this->set(CodeGenerator::class, function($di) {
70
+return new CodeGenerator(Jaxon::VERSION, $di->g(Container::class),
71
+    $di->g(TemplateEngine::class));
72
+});
73
+$this->set(ConfigScriptGenerator::class, function($di) {
74
+return new ConfigScriptGenerator($di->g(ParameterReader::class),
75
+    $di->g(TemplateEngine::class), $di->g(ConfigManager::class));
76
+});
77
+$this->set(ReadyScriptGenerator::class, function($di) {
78
+return new ReadyScriptGenerator();
79
+});
80
+
81
+// Script response plugin
82
+$this->set(ScriptPlugin::class, function($di) {
83
+return new ScriptPlugin($di->g(CallFactory::class));
84
+});
85
+// Databag response plugin
86
+$this->set(DatabagPlugin::class, function($di) {
87
+return new DatabagPlugin($di->g(Container::class));
88
+});
89
+// Dialog response plugin
90
+$this->set(DialogPlugin::class, function($di) {
91
+return new DialogPlugin($di->g(DialogCommand::class));
92
+});
93
+// Paginator response plugin
94
+$this->set(PaginatorPlugin::class, function($di) {
95
+return new PaginatorPlugin($di->g(RendererInterface::class));
96
+});
97
+}
98
+
99
+/**
100 100
      * Get the plugin manager
101 101
      *
102 102
      * @return PluginManager
103 103
      */
104
-    public function getPluginManager(): PluginManager
105
-    {
106
-        return $this->g(PluginManager::class);
107
-    }
104
+public function getPluginManager(): PluginManager
105
+{
106
+return $this->g(PluginManager::class);
107
+}
108 108
 
109
-    /**
109
+/**
110 110
      * Get the package manager
111 111
      *
112 112
      * @return PackageManager
113 113
      */
114
-    public function getPackageManager(): PackageManager
115
-    {
116
-        return $this->g(PackageManager::class);
117
-    }
114
+public function getPackageManager(): PackageManager
115
+{
116
+return $this->g(PackageManager::class);
117
+}
118 118
 
119
-    /**
119
+/**
120 120
      * Get the code generator
121 121
      *
122 122
      * @return CodeGenerator
123 123
      */
124
-    public function getCodeGenerator(): CodeGenerator
125
-    {
126
-        return $this->g(CodeGenerator::class);
127
-    }
124
+public function getCodeGenerator(): CodeGenerator
125
+{
126
+return $this->g(CodeGenerator::class);
127
+}
128 128
 
129
-    /**
129
+/**
130 130
      * Get the asset manager
131 131
      *
132 132
      * @return AssetManager
133 133
      */
134
-    public function getAssetManager(): AssetManager
135
-    {
136
-        return $this->g(AssetManager::class);
137
-    }
134
+public function getAssetManager(): AssetManager
135
+{
136
+return $this->g(AssetManager::class);
137
+}
138 138
 
139
-    /**
139
+/**
140 140
      * Get the jQuery plugin
141 141
      *
142 142
      * @return ScriptPlugin
143 143
      */
144
-    public function getScriptPlugin(): ScriptPlugin
145
-    {
146
-        return $this->g(ScriptPlugin::class);
147
-    }
144
+public function getScriptPlugin(): ScriptPlugin
145
+{
146
+return $this->g(ScriptPlugin::class);
147
+}
148 148
 
149
-    /**
149
+/**
150 150
      * Get the dialog plugin
151 151
      *
152 152
      * @return DialogPlugin
153 153
      */
154
-    public function getDialogPlugin(): DialogPlugin
155
-    {
156
-        return $this->g(DialogPlugin::class);
157
-    }
154
+public function getDialogPlugin(): DialogPlugin
155
+{
156
+return $this->g(DialogPlugin::class);
157
+}
158 158
 
159
-    /**
159
+/**
160 160
      * @param class-string $sClassName    The package class name
161 161
      *
162 162
      * @return string
163 163
      */
164
-    private function getPackageConfigKey(string $sClassName): string
165
-    {
166
-        return $sClassName . '_PackageConfig';
167
-    }
164
+private function getPackageConfigKey(string $sClassName): string
165
+{
166
+return $sClassName . '_PackageConfig';
167
+}
168 168
 
169
-    /**
169
+/**
170 170
      * @param class-string $sClassName    The package class name
171 171
      * @param-closure-this AbstractPackage $cSetter
172 172
      *
173 173
      * @return void
174 174
      */
175
-    private function extendPackage(string $sClassName, Closure $cSetter): void
176
-    {
177
-        // Initialize the package instance.
178
-        $this->xLibContainer->extend($sClassName, function($xPackage) use($cSetter) {
179
-            // Allow the setter to access protected attributes.
180
-            call_user_func($cSetter->bindTo($xPackage, $xPackage));
181
-            return $xPackage;
182
-        });
183
-    }
184
-
185
-    /**
175
+private function extendPackage(string $sClassName, Closure $cSetter): void
176
+{
177
+// Initialize the package instance.
178
+$this->xLibContainer->extend($sClassName, function($xPackage) use($cSetter) {
179
+// Allow the setter to access protected attributes.
180
+call_user_func($cSetter->bindTo($xPackage, $xPackage));
181
+return $xPackage;
182
+});
183
+}
184
+
185
+/**
186 186
      * Register a package
187 187
      *
188 188
      * @param class-string $sClassName    The package class name
@@ -191,45 +191,45 @@  discard block
 block discarded – undo
191 191
      * @return void
192 192
      * @throws SetupException
193 193
      */
194
-    public function registerPackage(string $sClassName, array $aUserOptions): void
195
-    {
196
-        // Register the user class, but only if the user didn't already.
197
-        if(!$this->h($sClassName))
198
-        {
199
-            $this->set($sClassName, fn() => $this->make($sClassName));
200
-        }
201
-
202
-        // Save the package config in the container.
203
-        $sConfigKey = $this->getPackageConfigKey($sClassName);
204
-        $this->set($sConfigKey, function($di) use($aUserOptions) {
205
-            $xOptionsProvider = $aUserOptions['provider'] ?? null;
206
-            // The user can provide a callable that returns the package options.
207
-            if(is_callable($xOptionsProvider))
208
-            {
209
-                $aUserOptions = $xOptionsProvider($aUserOptions);
210
-            }
211
-            return $di->g(ConfigManager::class)->newConfig($aUserOptions);
212
-        });
213
-
214
-        // Initialize the package instance.
215
-        $di = $this;
216
-        $this->extendPackage($sClassName, function() use($di, $sConfigKey) {
217
-            // $this here refers to the AbstractPackage instance.
218
-            $this->xPkgConfig = $di->g($sConfigKey);
219
-            $this->xRenderer = $di->g(ViewRenderer::class);
220
-            $this->init();
221
-        });
222
-    }
223
-
224
-    /**
194
+public function registerPackage(string $sClassName, array $aUserOptions): void
195
+{
196
+// Register the user class, but only if the user didn't already.
197
+if(!$this->h($sClassName))
198
+{
199
+$this->set($sClassName, fn() => $this->make($sClassName));
200
+}
201
+
202
+// Save the package config in the container.
203
+$sConfigKey = $this->getPackageConfigKey($sClassName);
204
+$this->set($sConfigKey, function($di) use($aUserOptions) {
205
+$xOptionsProvider = $aUserOptions['provider'] ?? null;
206
+// The user can provide a callable that returns the package options.
207
+if(is_callable($xOptionsProvider))
208
+{
209
+    $aUserOptions = $xOptionsProvider($aUserOptions);
210
+}
211
+return $di->g(ConfigManager::class)->newConfig($aUserOptions);
212
+});
213
+
214
+// Initialize the package instance.
215
+$di = $this;
216
+$this->extendPackage($sClassName, function() use($di, $sConfigKey) {
217
+// $this here refers to the AbstractPackage instance.
218
+$this->xPkgConfig = $di->g($sConfigKey);
219
+$this->xRenderer = $di->g(ViewRenderer::class);
220
+$this->init();
221
+});
222
+}
223
+
224
+/**
225 225
      * Get the config of a package
226 226
      *
227 227
      * @param class-string $sClassName    The package class name
228 228
      *
229 229
      * @return Config
230 230
      */
231
-    public function getPackageConfig(string $sClassName): Config
232
-    {
233
-        return $this->g($this->getPackageConfigKey($sClassName));
234
-    }
231
+public function getPackageConfig(string $sClassName): Config
232
+{
233
+return $this->g($this->getPackageConfigKey($sClassName));
234
+}
235 235
 }
Please login to merge, or discard this patch.
jaxon-core/src/App/Pagination/Page.php 1 patch
Switch Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -13,25 +13,25 @@
 block discarded – undo
13 13
 
14 14
 class Page
15 15
 {
16
-    /**
16
+/**
17 17
      * @var string
18 18
      */
19
-    public $sType;
19
+public $sType;
20 20
 
21
-    /**
21
+/**
22 22
      * @var string
23 23
      */
24
-    public $sText;
24
+public $sText;
25 25
 
26
-    /**
26
+/**
27 27
      * @var int
28 28
      */
29
-    public $nNumber;
29
+public $nNumber;
30 30
 
31
-    public function __construct(string $sType, string $sText, int $nNumber)
32
-    {
33
-        $this->sType = $sType;
34
-        $this->sText = $sText;
35
-        $this->nNumber = $nNumber;
36
-    }
31
+public function __construct(string $sType, string $sText, int $nNumber)
32
+{
33
+$this->sType = $sType;
34
+$this->sText = $sText;
35
+$this->nNumber = $nNumber;
36
+}
37 37
 }
38 38
\ No newline at end of file
Please login to merge, or discard this patch.
jaxon-core/src/App/View/Store.php 1 patch
Switch Indentation   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -9,35 +9,35 @@  discard block
 block discarded – undo
9 9
 
10 10
 class Store implements JsonSerializable, Stringable
11 11
 {
12
-    /**
12
+/**
13 13
      * The view renderer
14 14
      *
15 15
      * @var ViewInterface|null
16 16
      */
17
-    protected $xRenderer = null;
17
+protected $xRenderer = null;
18 18
 
19
-    /**
19
+/**
20 20
      * The view namespace
21 21
      *
22 22
      * @var string
23 23
      */
24
-    protected $sNamespace;
24
+protected $sNamespace;
25 25
 
26
-    /**
26
+/**
27 27
      * The view name
28 28
      *
29 29
      * @var string
30 30
      */
31
-    protected $sViewName;
31
+protected $sViewName;
32 32
 
33
-    /**
33
+/**
34 34
      * The view data
35 35
      *
36 36
      * @var array
37 37
      */
38
-    protected $aViewData = [];
38
+protected $aViewData = [];
39 39
 
40
-    /**
40
+/**
41 41
      * Make a piece of data available for the rendered view
42 42
      *
43 43
      * @param string $sName    The data name
@@ -45,26 +45,26 @@  discard block
 block discarded – undo
45 45
      *
46 46
      * @return Store
47 47
      */
48
-    public function with(string $sName, $xValue): Store
49
-    {
50
-        $this->aViewData[$sName] = $xValue;
51
-        return $this;
52
-    }
48
+public function with(string $sName, $xValue): Store
49
+{
50
+$this->aViewData[$sName] = $xValue;
51
+return $this;
52
+}
53 53
 
54
-    /**
54
+/**
55 55
      * Set the data to be rendered
56 56
      *
57 57
      * @param array $aViewData    The view data
58 58
      *
59 59
      * @return Store
60 60
      */
61
-    public function setData(array $aViewData): Store
62
-    {
63
-        $this->aViewData = array_merge($this->aViewData, $aViewData);
64
-        return $this;
65
-    }
61
+public function setData(array $aViewData): Store
62
+{
63
+$this->aViewData = array_merge($this->aViewData, $aViewData);
64
+return $this;
65
+}
66 66
 
67
-    /**
67
+/**
68 68
      * Set the view to be rendered, with optional data
69 69
      *
70 70
      * @param ViewInterface $xRenderer    The view renderer
@@ -74,65 +74,65 @@  discard block
 block discarded – undo
74 74
      *
75 75
      * @return Store
76 76
      */
77
-    public function setView(ViewInterface $xRenderer,
78
-        string $sNamespace, string $sViewName, array $aViewData = []): Store
79
-    {
80
-        $this->xRenderer = $xRenderer;
81
-        $this->sNamespace = trim($sNamespace);
82
-        $this->sViewName = trim($sViewName);
83
-        $this->aViewData = array_merge($this->aViewData, $aViewData);
84
-        return $this;
85
-    }
77
+public function setView(ViewInterface $xRenderer,
78
+string $sNamespace, string $sViewName, array $aViewData = []): Store
79
+{
80
+$this->xRenderer = $xRenderer;
81
+$this->sNamespace = trim($sNamespace);
82
+$this->sViewName = trim($sViewName);
83
+$this->aViewData = array_merge($this->aViewData, $aViewData);
84
+return $this;
85
+}
86 86
 
87
-    /**
87
+/**
88 88
      * Get the view namespace
89 89
      *
90 90
      * @return string        The view namespace
91 91
      */
92
-    public function getNamespace(): string
93
-    {
94
-        return $this->sNamespace;
95
-    }
92
+public function getNamespace(): string
93
+{
94
+return $this->sNamespace;
95
+}
96 96
 
97
-    /**
97
+/**
98 98
      * Get the view name
99 99
      *
100 100
      * @return string        The view name
101 101
      */
102
-    public function getViewName(): string
103
-    {
104
-        return $this->sViewName;
105
-    }
102
+public function getViewName(): string
103
+{
104
+return $this->sViewName;
105
+}
106 106
 
107
-    /**
107
+/**
108 108
      * Get the view data
109 109
      *
110 110
      * @return array         The view data
111 111
      */
112
-    public function getViewData(): array
113
-    {
114
-        return $this->aViewData;
115
-    }
112
+public function getViewData(): array
113
+{
114
+return $this->aViewData;
115
+}
116 116
 
117
-    /**
117
+/**
118 118
      * Render a view using third party view system
119 119
      *
120 120
      * @return string        The string representation of the view
121 121
      */
122
-    public function __toString(): string
123
-    {
124
-        return !$this->xRenderer ? '' : $this->xRenderer->render($this);
125
-    }
122
+public function __toString(): string
123
+{
124
+return !$this->xRenderer ? '' : $this->xRenderer->render($this);
125
+}
126 126
 
127
-    /**
127
+/**
128 128
      * Convert this object to string for json.
129 129
      *
130 130
      * This is a method of the JsonSerializable interface.
131 131
      *
132 132
      * @return string
133 133
      */
134
-    public function jsonSerialize(): string
135
-    {
136
-        return $this->__toString();
137
-    }
134
+public function jsonSerialize(): string
135
+{
136
+return $this->__toString();
137
+}
138 138
 }
Please login to merge, or discard this patch.
jaxon-core/src/App/View/ViewRenderer.php 1 patch
Switch Indentation   +151 added lines, -151 removed lines patch added patch discarded remove patch
@@ -13,58 +13,58 @@  discard block
 block discarded – undo
13 13
 
14 14
 class ViewRenderer
15 15
 {
16
-    /**
16
+/**
17 17
      * @var Container
18 18
      */
19
-    protected $di;
19
+protected $di;
20 20
 
21
-    /**
21
+/**
22 22
      * The view data store
23 23
      *
24 24
      * @var Store|null
25 25
      */
26
-    protected $xStore = null;
26
+protected $xStore = null;
27 27
 
28
-    /**
28
+/**
29 29
      * The view data store
30 30
      *
31 31
      * @var Store
32 32
      */
33
-    protected $xEmptyStore = null;
33
+protected $xEmptyStore = null;
34 34
 
35
-    /**
35
+/**
36 36
      * The view namespaces
37 37
      *
38 38
      * @var array
39 39
      */
40
-    protected $aNamespaces = [];
40
+protected $aNamespaces = [];
41 41
 
42
-    /**
42
+/**
43 43
      * The default namespace
44 44
      *
45 45
      * @var string
46 46
      */
47
-    protected $sDefaultNamespace = 'jaxon';
47
+protected $sDefaultNamespace = 'jaxon';
48 48
 
49
-    /**
49
+/**
50 50
      * The view global data
51 51
      *
52 52
      * @var array
53 53
      */
54
-    protected $aViewData = [];
54
+protected $aViewData = [];
55 55
 
56
-    /**
56
+/**
57 57
      * The class constructor
58 58
      *
59 59
      * @param Container $di
60 60
      */
61
-    public function __construct(Container $di)
62
-    {
63
-        $this->di = $di;
64
-        $this->xEmptyStore = new Store();
65
-    }
61
+public function __construct(Container $di)
62
+{
63
+$this->di = $di;
64
+$this->xEmptyStore = new Store();
65
+}
66 66
 
67
-    /**
67
+/**
68 68
      * Add a view namespace, and set the corresponding renderer.
69 69
      *
70 70
      * @param string $sNamespace    The namespace name
@@ -74,59 +74,59 @@  discard block
 block discarded – undo
74 74
      *
75 75
      * @return void
76 76
      */
77
-    public function addNamespace(string $sNamespace, string $sDirectory,
78
-        string $sExtension, string $sRenderer): void
79
-    {
80
-        $aNamespace = [
81
-            'directory' => $sDirectory,
82
-            'extension' => $sExtension,
83
-            'renderer' => $sRenderer,
84
-        ];
85
-        $this->aNamespaces[$sNamespace] = $aNamespace;
86
-    }
77
+public function addNamespace(string $sNamespace, string $sDirectory,
78
+string $sExtension, string $sRenderer): void
79
+{
80
+$aNamespace = [
81
+'directory' => $sDirectory,
82
+'extension' => $sExtension,
83
+'renderer' => $sRenderer,
84
+];
85
+$this->aNamespaces[$sNamespace] = $aNamespace;
86
+}
87 87
 
88
-    /**
88
+/**
89 89
      * Set the view namespaces.
90 90
      *
91 91
      * @param Config $xAppConfig    The config options provided in the library
92 92
      *
93 93
      * @return void
94 94
      */
95
-    public function addNamespaces(Config $xAppConfig): void
96
-    {
97
-        if(empty($aNamespaces = $xAppConfig->getOptionNames('views')))
98
-        {
99
-            return;
100
-        }
95
+public function addNamespaces(Config $xAppConfig): void
96
+{
97
+if(empty($aNamespaces = $xAppConfig->getOptionNames('views')))
98
+{
99
+return;
100
+}
101 101
 
102
-        $sPackage = $xAppConfig->getOption('package', '');
103
-        foreach($aNamespaces as $sNamespace => $sOption)
104
-        {
105
-            // Save the namespace
106
-            $aNamespace = $xAppConfig->getOption($sOption);
107
-            $aNamespace['package'] = $sPackage;
108
-            if(!isset($aNamespace['renderer']))
109
-            {
110
-                $aNamespace['renderer'] = 'jaxon'; // 'jaxon' is the default renderer.
111
-            }
112
-            $this->aNamespaces[$sNamespace] = $aNamespace;
113
-        }
114
-    }
102
+$sPackage = $xAppConfig->getOption('package', '');
103
+foreach($aNamespaces as $sNamespace => $sOption)
104
+{
105
+// Save the namespace
106
+$aNamespace = $xAppConfig->getOption($sOption);
107
+$aNamespace['package'] = $sPackage;
108
+if(!isset($aNamespace['renderer']))
109
+{
110
+    $aNamespace['renderer'] = 'jaxon'; // 'jaxon' is the default renderer.
111
+}
112
+$this->aNamespaces[$sNamespace] = $aNamespace;
113
+}
114
+}
115 115
 
116
-    /**
116
+/**
117 117
      * Get the view renderer
118 118
      *
119 119
      * @param string $sId    The unique identifier of the view renderer
120 120
      *
121 121
      * @return ViewInterface
122 122
      */
123
-    public function getRenderer(string $sId): ViewInterface
124
-    {
125
-        // Return the view renderer with the given id
126
-        return $this->di->g("jaxon.app.view.$sId");
127
-    }
123
+public function getRenderer(string $sId): ViewInterface
124
+{
125
+// Return the view renderer with the given id
126
+return $this->di->g("jaxon.app.view.$sId");
127
+}
128 128
 
129
-    /**
129
+/**
130 130
      * Add a view renderer with an id
131 131
      *
132 132
      * @param string $sId    The unique identifier of the view renderer
@@ -134,25 +134,25 @@  discard block
 block discarded – undo
134 134
      *
135 135
      * @return void
136 136
      */
137
-    public function addRenderer(string $sId, Closure $xClosure): void
138
-    {
139
-        // Return the initialized view renderer
140
-        $this->di->set("jaxon.app.view.$sId", function($di) use($sId, $xClosure) {
141
-            // Get the defined renderer
142
-            $xRenderer = $xClosure($di);
143
-            // Init the renderer with the template namespaces
144
-            $aNamespaces = array_filter($this->aNamespaces, function($aOptions) use($sId) {
145
-                return $aOptions['renderer'] === $sId;
146
-            });
147
-            foreach($aNamespaces as $sName => $aOptions)
148
-            {
149
-                $xRenderer->addNamespace($sName, $aOptions['directory'], $aOptions['extension']);
150
-            }
151
-            return $xRenderer;
152
-        });
153
-    }
137
+public function addRenderer(string $sId, Closure $xClosure): void
138
+{
139
+// Return the initialized view renderer
140
+$this->di->set("jaxon.app.view.$sId", function($di) use($sId, $xClosure) {
141
+// Get the defined renderer
142
+$xRenderer = $xClosure($di);
143
+// Init the renderer with the template namespaces
144
+$aNamespaces = array_filter($this->aNamespaces, function($aOptions) use($sId) {
145
+    return $aOptions['renderer'] === $sId;
146
+});
147
+foreach($aNamespaces as $sName => $aOptions)
148
+{
149
+    $xRenderer->addNamespace($sName, $aOptions['directory'], $aOptions['extension']);
150
+}
151
+return $xRenderer;
152
+});
153
+}
154 154
 
155
-    /**
155
+/**
156 156
      * Add a view renderer with an id
157 157
      *
158 158
      * @param string $sId    The unique identifier of the view renderer
@@ -161,55 +161,55 @@  discard block
 block discarded – undo
161 161
      *
162 162
      * @return void
163 163
      */
164
-    public function setDefaultRenderer(string $sId, string $sExtension, Closure $xClosure): void
165
-    {
166
-        $this->setDefaultNamespace($sId);
167
-        $this->addNamespace($sId, '', $sExtension, $sId);
168
-        $this->addRenderer($sId, $xClosure);
169
-    }
164
+public function setDefaultRenderer(string $sId, string $sExtension, Closure $xClosure): void
165
+{
166
+$this->setDefaultNamespace($sId);
167
+$this->addNamespace($sId, '', $sExtension, $sId);
168
+$this->addRenderer($sId, $xClosure);
169
+}
170 170
 
171
-    /**
171
+/**
172 172
      * Get the view renderer for a given namespace
173 173
      *
174 174
      * @param string $sNamespace    The namespace name
175 175
      *
176 176
      * @return ViewInterface|null
177 177
      */
178
-    public function getNamespaceRenderer(string $sNamespace): ?ViewInterface
179
-    {
180
-        if(!isset($this->aNamespaces[$sNamespace]))
181
-        {
182
-            return null;
183
-        }
184
-        // Return the view renderer with the configured id
185
-        return $this->getRenderer($this->aNamespaces[$sNamespace]['renderer']);
186
-    }
178
+public function getNamespaceRenderer(string $sNamespace): ?ViewInterface
179
+{
180
+if(!isset($this->aNamespaces[$sNamespace]))
181
+{
182
+return null;
183
+}
184
+// Return the view renderer with the configured id
185
+return $this->getRenderer($this->aNamespaces[$sNamespace]['renderer']);
186
+}
187 187
 
188
-    /**
188
+/**
189 189
      * Set the default namespace
190 190
      *
191 191
      * @param string $sDefaultNamespace
192 192
      */
193
-    public function setDefaultNamespace(string $sDefaultNamespace): void
194
-    {
195
-        $this->sDefaultNamespace = $sDefaultNamespace;
196
-    }
193
+public function setDefaultNamespace(string $sDefaultNamespace): void
194
+{
195
+$this->sDefaultNamespace = $sDefaultNamespace;
196
+}
197 197
 
198
-    /**
198
+/**
199 199
      * Get the current store or create a new store
200 200
      *
201 201
      * @return Store
202 202
      */
203
-    protected function store(): Store
204
-    {
205
-        if(!$this->xStore)
206
-        {
207
-            $this->xStore = new Store();
208
-        }
209
-        return $this->xStore;
210
-    }
203
+protected function store(): Store
204
+{
205
+if(!$this->xStore)
206
+{
207
+$this->xStore = new Store();
208
+}
209
+return $this->xStore;
210
+}
211 211
 
212
-    /**
212
+/**
213 213
      * Make a piece of data available for the rendered view
214 214
      *
215 215
      * @param string $sName    The data name
@@ -217,13 +217,13 @@  discard block
 block discarded – undo
217 217
      *
218 218
      * @return ViewRenderer
219 219
      */
220
-    public function set(string $sName, $xValue): ViewRenderer
221
-    {
222
-        $this->store()->with($sName, $xValue);
223
-        return $this;
224
-    }
220
+public function set(string $sName, $xValue): ViewRenderer
221
+{
222
+$this->store()->with($sName, $xValue);
223
+return $this;
224
+}
225 225
 
226
-    /**
226
+/**
227 227
      * Make a piece of data available for all views
228 228
      *
229 229
      * @param string $sName    The data name
@@ -231,29 +231,29 @@  discard block
 block discarded – undo
231 231
      *
232 232
      * @return ViewRenderer
233 233
      */
234
-    public function share(string $sName, $xValue): ViewRenderer
235
-    {
236
-        $this->aViewData[$sName] = $xValue;
237
-        return $this;
238
-    }
234
+public function share(string $sName, $xValue): ViewRenderer
235
+{
236
+$this->aViewData[$sName] = $xValue;
237
+return $this;
238
+}
239 239
 
240
-    /**
240
+/**
241 241
      * Make an array of data available for all views
242 242
      *
243 243
      * @param array $aValues    The data values
244 244
      *
245 245
      * @return ViewRenderer
246 246
      */
247
-    public function shareValues(array $aValues): ViewRenderer
248
-    {
249
-        foreach($aValues as $sName => $xValue)
250
-        {
251
-            $this->share($sName, $xValue);
252
-        }
253
-        return $this;
254
-    }
247
+public function shareValues(array $aValues): ViewRenderer
248
+{
249
+foreach($aValues as $sName => $xValue)
250
+{
251
+$this->share($sName, $xValue);
252
+}
253
+return $this;
254
+}
255 255
 
256
-    /**
256
+/**
257 257
      * Render a view using a store
258 258
      *
259 259
      * The store returned by this function will later be used with the make() method to render the view.
@@ -263,32 +263,32 @@  discard block
 block discarded – undo
263 263
      *
264 264
      * @return Store   A store populated with the view data
265 265
      */
266
-    public function render(string $sViewName, array $aViewData = []): Store
267
-    {
268
-        $xStore = $this->store();
269
-        // Get the default view namespace
270
-        $sNamespace = $this->sDefaultNamespace;
271
-        // Get the namespace from the view name
272
-        $nSeparatorPosition = strrpos($sViewName, '::');
273
-        if($nSeparatorPosition !== false)
274
-        {
275
-            $sNamespace = substr($sViewName, 0, $nSeparatorPosition);
276
-            $sViewName = substr($sViewName, $nSeparatorPosition + 2);
277
-        }
266
+public function render(string $sViewName, array $aViewData = []): Store
267
+{
268
+$xStore = $this->store();
269
+// Get the default view namespace
270
+$sNamespace = $this->sDefaultNamespace;
271
+// Get the namespace from the view name
272
+$nSeparatorPosition = strrpos($sViewName, '::');
273
+if($nSeparatorPosition !== false)
274
+{
275
+$sNamespace = substr($sViewName, 0, $nSeparatorPosition);
276
+$sViewName = substr($sViewName, $nSeparatorPosition + 2);
277
+}
278 278
 
279
-        $xRenderer = $this->getNamespaceRenderer($sNamespace);
280
-        if(!$xRenderer)
281
-        {
282
-            // Cannot render a view if there's no renderer corresponding to the namespace.
283
-            return $this->xEmptyStore;
284
-        }
279
+$xRenderer = $this->getNamespaceRenderer($sNamespace);
280
+if(!$xRenderer)
281
+{
282
+// Cannot render a view if there's no renderer corresponding to the namespace.
283
+return $this->xEmptyStore;
284
+}
285 285
 
286
-        $xStore->setData(array_merge($this->aViewData, $aViewData))
287
-            ->setView($xRenderer, $sNamespace, $sViewName);
286
+$xStore->setData(array_merge($this->aViewData, $aViewData))
287
+->setView($xRenderer, $sNamespace, $sViewName);
288 288
 
289
-        // Set the store to null so a new store will be created for the next view.
290
-        $this->xStore = null;
291
-        // Return the store
292
-        return $xStore;
293
-    }
289
+// Set the store to null so a new store will be created for the next view.
290
+$this->xStore = null;
291
+// Return the store
292
+return $xStore;
293
+}
294 294
 }
Please login to merge, or discard this patch.
jaxon-core/src/App/Metadata/Metadata.php 1 patch
Switch Indentation   +133 added lines, -133 removed lines patch added patch discarded remove patch
@@ -22,213 +22,213 @@
 block discarded – undo
22 22
 
23 23
 class Metadata
24 24
 {
25
-    /**
25
+/**
26 26
      * @var array<string, array<string, Data\AbstractData>>
27 27
      */
28
-    private array $aAttributes = [
29
-        'exclude' => [],
30
-        'export' => [],
31
-        'container' => [],
32
-        'databag' => [],
33
-        'callback' => [],
34
-        'before' => [],
35
-        'after' => [],
36
-        'upload' => [],
37
-    ];
38
-
39
-    /**
28
+private array $aAttributes = [
29
+'exclude' => [],
30
+'export' => [],
31
+'container' => [],
32
+'databag' => [],
33
+'callback' => [],
34
+'before' => [],
35
+'after' => [],
36
+'upload' => [],
37
+];
38
+
39
+/**
40 40
      * @return array<string, array<string, Data\AbstractData>>
41 41
      */
42
-    public function getAttributes(): array
43
-    {
44
-        return $this->aAttributes;
45
-    }
42
+public function getAttributes(): array
43
+{
44
+return $this->aAttributes;
45
+}
46 46
 
47
-    /**
47
+/**
48 48
      * @param string $sMethod
49 49
      *
50 50
      * @return Data\ExcludeData
51 51
      */
52
-    public function exclude(string $sMethod = '*'): Data\ExcludeData
53
-    {
54
-        return $this->aAttributes['exclude'][$sMethod] ??
55
-            $this->aAttributes['exclude'][$sMethod] = new Data\ExcludeData();
56
-    }
52
+public function exclude(string $sMethod = '*'): Data\ExcludeData
53
+{
54
+return $this->aAttributes['exclude'][$sMethod] ??
55
+$this->aAttributes['exclude'][$sMethod] = new Data\ExcludeData();
56
+}
57 57
 
58
-    /**
58
+/**
59 59
      * @param string $sMethod
60 60
      *
61 61
      * @return Data\ExportData
62 62
      */
63
-    public function export(string $sMethod = '*'): Data\ExportData
64
-    {
65
-        $sMethod = '*'; // On classes only
66
-        return $this->aAttributes['export'][$sMethod] ??
67
-            $this->aAttributes['export'][$sMethod] = new Data\ExportData();
68
-    }
63
+public function export(string $sMethod = '*'): Data\ExportData
64
+{
65
+$sMethod = '*'; // On classes only
66
+return $this->aAttributes['export'][$sMethod] ??
67
+$this->aAttributes['export'][$sMethod] = new Data\ExportData();
68
+}
69 69
 
70
-    /**
70
+/**
71 71
      * @param string $sMethod
72 72
      *
73 73
      * @return Data\ContainerData
74 74
      */
75
-    public function container(string $sMethod = '*'): Data\ContainerData
76
-    {
77
-        return $this->aAttributes['container'][$sMethod] ??
78
-            $this->aAttributes['container'][$sMethod] = new Data\ContainerData();
79
-    }
75
+public function container(string $sMethod = '*'): Data\ContainerData
76
+{
77
+return $this->aAttributes['container'][$sMethod] ??
78
+$this->aAttributes['container'][$sMethod] = new Data\ContainerData();
79
+}
80 80
 
81
-    /**
81
+/**
82 82
      * @param string $sMethod
83 83
      *
84 84
      * @return Data\DatabagData
85 85
      */
86
-    public function databag(string $sMethod = '*'): Data\DatabagData
87
-    {
88
-        return $this->aAttributes['databag'][$sMethod] ??
89
-            $this->aAttributes['databag'][$sMethod] = new Data\DatabagData();
90
-    }
86
+public function databag(string $sMethod = '*'): Data\DatabagData
87
+{
88
+return $this->aAttributes['databag'][$sMethod] ??
89
+$this->aAttributes['databag'][$sMethod] = new Data\DatabagData();
90
+}
91 91
 
92
-    /**
92
+/**
93 93
      * @param string $sMethod
94 94
      *
95 95
      * @return Data\CallbackData
96 96
      */
97
-    public function callback(string $sMethod = '*'): Data\CallbackData
98
-    {
99
-        return $this->aAttributes['callback'][$sMethod] ??
100
-            $this->aAttributes['callback'][$sMethod] = new Data\CallbackData();
101
-    }
97
+public function callback(string $sMethod = '*'): Data\CallbackData
98
+{
99
+return $this->aAttributes['callback'][$sMethod] ??
100
+$this->aAttributes['callback'][$sMethod] = new Data\CallbackData();
101
+}
102 102
 
103
-    /**
103
+/**
104 104
      * @param string $sMethod
105 105
      *
106 106
      * @return Data\BeforeData
107 107
      */
108
-    public function before(string $sMethod = '*'): Data\BeforeData
109
-    {
110
-        return $this->aAttributes['before'][$sMethod] ??
111
-            $this->aAttributes['before'][$sMethod] = new Data\BeforeData();
112
-    }
108
+public function before(string $sMethod = '*'): Data\BeforeData
109
+{
110
+return $this->aAttributes['before'][$sMethod] ??
111
+$this->aAttributes['before'][$sMethod] = new Data\BeforeData();
112
+}
113 113
 
114
-    /**
114
+/**
115 115
      * @param string $sMethod
116 116
      *
117 117
      * @return Data\AfterData
118 118
      */
119
-    public function after(string $sMethod = '*'): Data\AfterData
120
-    {
121
-        return $this->aAttributes['after'][$sMethod] ??
122
-            $this->aAttributes['after'][$sMethod] = new Data\AfterData();
123
-    }
119
+public function after(string $sMethod = '*'): Data\AfterData
120
+{
121
+return $this->aAttributes['after'][$sMethod] ??
122
+$this->aAttributes['after'][$sMethod] = new Data\AfterData();
123
+}
124 124
 
125
-    /**
125
+/**
126 126
      * @param string $sMethod
127 127
      *
128 128
      * @return Data\UploadData
129 129
      */
130
-    public function upload(string $sMethod = '*'): Data\UploadData
131
-    {
132
-        return $this->aAttributes['upload'][$sMethod] ??
133
-            $this->aAttributes['upload'][$sMethod] = new Data\UploadData();
134
-    }
130
+public function upload(string $sMethod = '*'): Data\UploadData
131
+{
132
+return $this->aAttributes['upload'][$sMethod] ??
133
+$this->aAttributes['upload'][$sMethod] = new Data\UploadData();
134
+}
135 135
 
136
-    /**
136
+/**
137 137
      * True if the class is excluded
138 138
      *
139 139
      * @return bool
140 140
      */
141
-    public function isExcluded(): bool
142
-    {
143
-        $xData = $this->aAttributes['exclude']['*'] ?? null;
144
-        return $xData !== null && $xData->getValue() === true;
145
-    }
141
+public function isExcluded(): bool
142
+{
143
+$xData = $this->aAttributes['exclude']['*'] ?? null;
144
+return $xData !== null && $xData->getValue() === true;
145
+}
146 146
 
147
-    /**
147
+/**
148 148
      * Get the properties of the class methods
149 149
      *
150 150
      * @return array
151 151
      */
152
-    public function getProperties(): array
152
+public function getProperties(): array
153
+{
154
+$aProperties = [];
155
+$aClassProperties = [];
156
+foreach($this->aAttributes as $sType => $aValues)
157
+{
158
+if($sType === 'exclude')
159
+{
160
+    continue;
161
+}
162
+
163
+foreach($aValues as $sMethod => $xData)
164
+{
165
+    if($sMethod === '*')
153 166
     {
154
-        $aProperties = [];
155
-        $aClassProperties = [];
156
-        foreach($this->aAttributes as $sType => $aValues)
157
-        {
158
-            if($sType === 'exclude')
159
-            {
160
-                continue;
161
-            }
162
-
163
-            foreach($aValues as $sMethod => $xData)
164
-            {
165
-                if($sMethod === '*')
166
-                {
167
-                    $aClassProperties[$xData->getName()] = $xData->getValue();
168
-                    continue;
169
-                }
170
-                $aProperties[$sMethod][$xData->getName()] = $xData->getValue();
171
-            }
172
-        }
173
-
174
-        if(count($aClassProperties) > 0)
175
-        {
176
-            $aProperties['*'] = $aClassProperties;
177
-        }
178
-
179
-        return $aProperties;
167
+        $aClassProperties[$xData->getName()] = $xData->getValue();
168
+        continue;
180 169
     }
170
+    $aProperties[$sMethod][$xData->getName()] = $xData->getValue();
171
+}
172
+}
181 173
 
182
-    /**
174
+if(count($aClassProperties) > 0)
175
+{
176
+$aProperties['*'] = $aClassProperties;
177
+}
178
+
179
+return $aProperties;
180
+}
181
+
182
+/**
183 183
      * Get the methods in the export attributes
184 184
      *
185 185
      * @return array
186 186
      */
187
-    public function getExportMethods(): array
188
-    {
189
-        /** @var array<Data\ExcludeData> */
190
-        $aAttributes = $this->aAttributes['exclude'];
191
-        $aExcludeMethods = array_keys($aAttributes);
192
-        $aExcludeMethods = array_values(array_filter($aExcludeMethods,
193
-            fn(string $sName) => $sName !== '*' &&
194
-                $aAttributes[$sName]->getValue() === true));
195
-
196
-        /** @var Data\ExportData|null */
197
-        $xExportData = $this->aAttributes['export']['*'] ?? null;
198
-        $aExportMethods = $xExportData?->getValue() ?? [];
199
-
200
-        $aExceptMethods = $aExportMethods['except'] ?? [];
201
-        $aExportMethods['except'] = array_merge($aExcludeMethods, $aExceptMethods);
202
-        return $aExportMethods;
203
-    }
187
+public function getExportMethods(): array
188
+{
189
+/** @var array<Data\ExcludeData> */
190
+$aAttributes = $this->aAttributes['exclude'];
191
+$aExcludeMethods = array_keys($aAttributes);
192
+$aExcludeMethods = array_values(array_filter($aExcludeMethods,
193
+fn(string $sName) => $sName !== '*' &&
194
+    $aAttributes[$sName]->getValue() === true));
195
+
196
+/** @var Data\ExportData|null */
197
+$xExportData = $this->aAttributes['export']['*'] ?? null;
198
+$aExportMethods = $xExportData?->getValue() ?? [];
199
+
200
+$aExceptMethods = $aExportMethods['except'] ?? [];
201
+$aExportMethods['except'] = array_merge($aExcludeMethods, $aExceptMethods);
202
+return $aExportMethods;
203
+}
204 204
 
205
-    /**
205
+/**
206 206
      * Get the exluded methods
207 207
      *
208 208
      * @return array
209 209
      */
210
-    public function getExceptMethods(): array
211
-    {
212
-        return $this->getExportMethods()['except'];
213
-    }
210
+public function getExceptMethods(): array
211
+{
212
+return $this->getExportMethods()['except'];
213
+}
214 214
 
215
-    /**
215
+/**
216 216
      * Get the export base methods
217 217
      *
218 218
      * @return array
219 219
      */
220
-    public function getExportBaseMethods(): array
221
-    {
222
-        return $this->getExportMethods()['base'] ?? [];
223
-    }
220
+public function getExportBaseMethods(): array
221
+{
222
+return $this->getExportMethods()['base'] ?? [];
223
+}
224 224
 
225
-    /**
225
+/**
226 226
      * Get the export only methods
227 227
      *
228 228
      * @return array
229 229
      */
230
-    public function getExportOnlyMethods(): array
231
-    {
232
-        return $this->getExportMethods()['only'] ?? [];
233
-    }
230
+public function getExportOnlyMethods(): array
231
+{
232
+return $this->getExportMethods()['only'] ?? [];
233
+}
234 234
 }
Please login to merge, or discard this patch.
jaxon-core/src/App/Metadata/Data/DatabagData.php 1 patch
Switch Indentation   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -22,61 +22,61 @@
 block discarded – undo
22 22
 
23 23
 class DatabagData extends AbstractData
24 24
 {
25
-    /**
25
+/**
26 26
      * The databag names
27 27
      *
28 28
      * @var array
29 29
      */
30
-    protected $aNames = [];
30
+protected $aNames = [];
31 31
 
32
-    /**
32
+/**
33 33
      * @return string
34 34
      */
35
-    public function getName(): string
36
-    {
37
-        return 'bags';
38
-    }
35
+public function getName(): string
36
+{
37
+return 'bags';
38
+}
39 39
 
40
-    /**
40
+/**
41 41
      * @return mixed
42 42
      */
43
-    public function getValue(): mixed
44
-    {
45
-        return array_values($this->aNames);
46
-    }
43
+public function getValue(): mixed
44
+{
45
+return array_values($this->aNames);
46
+}
47 47
 
48
-    /**
48
+/**
49 49
      * @param string $sName
50 50
      *
51 51
      * @return void
52 52
      */
53
-    protected function validateName(string $sName): void
54
-    {
55
-        if(preg_match('/^[a-zA-Z][a-zA-Z0-9_\-\.]*$/', $sName) > 0)
56
-        {
57
-            return;
58
-        }
59
-        throw new SetupException("$sName is not a valid \"name\" value for databag");
60
-    }
53
+protected function validateName(string $sName): void
54
+{
55
+if(preg_match('/^[a-zA-Z][a-zA-Z0-9_\-\.]*$/', $sName) > 0)
56
+{
57
+return;
58
+}
59
+throw new SetupException("$sName is not a valid \"name\" value for databag");
60
+}
61 61
 
62
-    /**
62
+/**
63 63
      * @param string $sName
64 64
      *
65 65
      * @return void
66 66
      */
67
-    public function addValue(string $sName): void
68
-    {
69
-        $this->validateName($sName);
67
+public function addValue(string $sName): void
68
+{
69
+$this->validateName($sName);
70 70
 
71
-        $this->aNames[$sName] = $sName;
72
-    }
71
+$this->aNames[$sName] = $sName;
72
+}
73 73
 
74
-    /**
74
+/**
75 75
      * @inheritDoc
76 76
      */
77
-    public function encode(string $sVarName): array
78
-    {
79
-        return array_map(fn($sName) =>
80
-            "{$sVarName}->addValue('$sName');", $this->aNames);
81
-    }
77
+public function encode(string $sVarName): array
78
+{
79
+return array_map(fn($sName) =>
80
+"{$sVarName}->addValue('$sName');", $this->aNames);
81
+}
82 82
 }
Please login to merge, or discard this patch.