Passed
Push — main ( ca0571...5ee2f7 )
by Thierry
03:43
created
jaxon-core/src/Plugin/Request/CallableClass/CallableClassPlugin.php 2 patches
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -85,8 +85,7 @@  discard block
 block discarded – undo
85 85
         if(is_string($xOptions))
86 86
         {
87 87
             $xOptions = ['include' => $xOptions];
88
-        }
89
-        elseif(!is_array($xOptions))
88
+        } elseif(!is_array($xOptions))
90 89
         {
91 90
             throw new SetupException($this->xTranslator->trans('errors.objects.invalid-declaration'));
92 91
         }
@@ -261,8 +260,7 @@  discard block
 block discarded – undo
261 260
 
262 261
             $sError = 'errors.objects.call';
263 262
             $xCallableObject->call($this->xTarget);
264
-        }
265
-        catch(ReflectionException|SetupException $e)
263
+        } catch(ReflectionException|SetupException $e)
266 264
         {
267 265
             // Unable to execute the requested class or method
268 266
             $this->throwException($e->getMessage(), $sError, $aErrorParams);
Please login to merge, or discard this patch.
Spacing   +13 added lines, -14 removed lines patch added patch discarded remove patch
@@ -81,15 +81,15 @@  discard block
 block discarded – undo
81 81
      */
82 82
     public function checkOptions(string $sCallable, $xOptions): array
83 83
     {
84
-        if(!$this->xValidator->validateClass(trim($sCallable)))
84
+        if (!$this->xValidator->validateClass(trim($sCallable)))
85 85
         {
86 86
             throw new SetupException($this->xTranslator->trans('errors.objects.invalid-declaration'));
87 87
         }
88
-        if(is_string($xOptions))
88
+        if (is_string($xOptions))
89 89
         {
90 90
             $xOptions = ['include' => $xOptions];
91 91
         }
92
-        elseif(!is_array($xOptions))
92
+        elseif (!is_array($xOptions))
93 93
         {
94 94
             throw new SetupException($this->xTranslator->trans('errors.objects.invalid-declaration'));
95 95
         }
@@ -133,15 +133,15 @@  discard block
 block discarded – undo
133 133
      */
134 134
     private function addCallable(CallableObject $xCallableObject): void
135 135
     {
136
-        if($xCallableObject->excluded())
136
+        if ($xCallableObject->excluded())
137 137
         {
138 138
             return;
139 139
         }
140 140
 
141 141
         $aCallableObject = &$this->aCallableObjects;
142
-        foreach(explode('.', $xCallableObject->getJsName()) as $sName)
142
+        foreach (explode('.', $xCallableObject->getJsName()) as $sName)
143 143
         {
144
-            if(!isset($aCallableObject['children'][$sName]))
144
+            if (!isset($aCallableObject['children'][$sName]))
145 145
             {
146 146
                 $aCallableObject['children'][$sName] = [];
147 147
             }
@@ -176,11 +176,10 @@  discard block
 block discarded – undo
176 176
 
177 177
         $fMethodCallback = fn($aMethod) => $this->renderMethod($sIndent,
178 178
             ['sJsClass' => $sJsClass, 'aMethod' => $aMethod]);
179
-        $aMethods = !isset($aCallable['methods']) ? [] :
180
-            array_map($fMethodCallback, $aCallable['methods']);
179
+        $aMethods = !isset($aCallable['methods']) ? [] : array_map($fMethodCallback, $aCallable['methods']);
181 180
 
182 181
         $aChildren = [];
183
-        foreach($aCallable['children'] ?? [] as $sName => $aChild)
182
+        foreach ($aCallable['children'] ?? [] as $sName => $aChild)
184 183
         {
185 184
             $aChildren[] = $this->renderChild("$sName:", "$sJsClass.$sName",
186 185
                 $aChild, $nRepeat) . ',';
@@ -221,13 +220,13 @@  discard block
 block discarded – undo
221 220
         $this->xRegistry->registerAllComponents();
222 221
 
223 222
         $this->aCallableObjects = ['children' => []];
224
-        foreach($this->cdi->getCallableObjects() as $xCallableObject)
223
+        foreach ($this->cdi->getCallableObjects() as $xCallableObject)
225 224
         {
226 225
             $this->addCallable($xCallableObject);
227 226
         }
228 227
 
229 228
         $aScripts = [];
230
-        foreach($this->aCallableObjects['children'] as $sJsClass => $aCallable)
229
+        foreach ($this->aCallableObjects['children'] as $sJsClass => $aCallable)
231 230
         {
232 231
             $aScripts[] = $this->renderChild("{$this->sPrefix}$sJsClass =",
233 232
                 $sJsClass, $aCallable) . ';';
@@ -283,7 +282,7 @@  discard block
 block discarded – undo
283 282
         // Will be used to print a translated error message.
284 283
         $aErrorParams = ['class' => $sClassName, 'method' => $sMethodName];
285 284
 
286
-        if(!$this->xValidator->validateJsObject($sClassName) ||
285
+        if (!$this->xValidator->validateJsObject($sClassName) ||
287 286
             !$this->xValidator->validateMethod($sMethodName))
288 287
         {
289 288
             // Unable to find the requested object or method
@@ -297,7 +296,7 @@  discard block
 block discarded – undo
297 296
             /** @var CallableObject */
298 297
             $xCallableObject = $this->getCallable($sClassName);
299 298
 
300
-            if($xCallableObject->excluded($sMethodName))
299
+            if ($xCallableObject->excluded($sMethodName))
301 300
             {
302 301
                 // Unable to find the requested class or method
303 302
                 $this->throwException('', 'errors.objects.excluded', $aErrorParams);
@@ -306,7 +305,7 @@  discard block
 block discarded – undo
306 305
             $sError = 'errors.objects.call';
307 306
             $xCallableObject->call($this->xTarget);
308 307
         }
309
-        catch(ReflectionException|SetupException $e)
308
+        catch (ReflectionException|SetupException $e)
310 309
         {
311 310
             // Unable to execute the requested class or method
312 311
             $this->throwException($e->getMessage(), $sError, $aErrorParams);
Please login to merge, or discard this patch.
jaxon-core/src/Request/Upload/UploadHandlerInterface.php 1 patch
Switch Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -20,45 +20,45 @@
 block discarded – undo
20 20
 
21 21
 interface UploadHandlerInterface
22 22
 {
23
-    /**
23
+/**
24 24
      * Set the uploaded file name sanitizer
25 25
      *
26 26
      * @param Closure $cSanitizer    The closure
27 27
      *
28 28
      * @return void
29 29
      */
30
-    public function sanitizer(Closure $cSanitizer);
30
+public function sanitizer(Closure $cSanitizer);
31 31
 
32
-    /**
32
+/**
33 33
      * Get the uploaded files
34 34
      *
35 35
      * @return FileInterface[]
36 36
      */
37
-    public function files(): array;
37
+public function files(): array;
38 38
 
39
-    /**
39
+/**
40 40
      * Check if the current request contains uploaded files
41 41
      *
42 42
      * @param ServerRequestInterface $xRequest
43 43
      *
44 44
      * @return bool
45 45
      */
46
-    public function canProcessRequest(ServerRequestInterface $xRequest): bool;
46
+public function canProcessRequest(ServerRequestInterface $xRequest): bool;
47 47
 
48
-    /**
48
+/**
49 49
      * Process the uploaded files in the HTTP request
50 50
      *
51 51
      * @param ServerRequestInterface $xRequest
52 52
      *
53 53
      * @return bool
54 54
      */
55
-    public function processRequest(ServerRequestInterface $xRequest): bool;
55
+public function processRequest(ServerRequestInterface $xRequest): bool;
56 56
 
57
-    /**
57
+/**
58 58
      * @param string $sStorage
59 59
      * @param Closure $cFactory
60 60
      *
61 61
      * @return void
62 62
      */
63
-    public function registerStorageAdapter(string $sStorage, Closure $cFactory);
63
+public function registerStorageAdapter(string $sStorage, Closure $cFactory);
64 64
 }
Please login to merge, or discard this patch.
jaxon-upload/tests/TestUpload/UploadFsLocalTest.php 1 patch
Switch Indentation   +130 added lines, -130 removed lines patch added patch discarded remove patch
@@ -19,163 +19,163 @@
 block discarded – undo
19 19
 
20 20
 class UploadFsLocalTest extends TestCase
21 21
 {
22
-    /**
22
+/**
23 23
      * @var string
24 24
      */
25
-    protected $sNameWhite;
25
+protected $sNameWhite;
26 26
 
27
-    /**
27
+/**
28 28
      * @var string
29 29
      */
30
-    protected $sPathWhite;
30
+protected $sPathWhite;
31 31
 
32
-    /**
32
+/**
33 33
      * @var int
34 34
      */
35
-    protected $sSizeWhite;
35
+protected $sSizeWhite;
36 36
 
37
-    /**
37
+/**
38 38
      * @var string
39 39
      */
40
-    protected $sNameBlue;
40
+protected $sNameBlue;
41 41
 
42
-    /**
42
+/**
43 43
      * @var string
44 44
      */
45
-    protected $sPathBlue;
45
+protected $sPathBlue;
46 46
 
47
-    /**
47
+/**
48 48
      * @var int
49 49
      */
50
-    protected $sSizeBlue;
50
+protected $sSizeBlue;
51 51
 
52
-    /**
52
+/**
53 53
      * @throws SetupException
54 54
      */
55
-    public function setUp(): void
56
-    {
57
-        jaxon()->di()->getPluginManager()->registerPlugins();
58
-        jaxon()->setOption('core.response.send', false);
59
-        jaxon()->setOption('upload.default.dir', __DIR__ . '/../upload/dst');
60
-        _register();
61
-
62
-        $tmpDir = __DIR__ . '/../upload/tmp';
63
-        @mkdir($tmpDir);
64
-
65
-        $sSrcWhite = __DIR__ . '/../upload/src/white.png';
66
-        $this->sNameWhite = 'white.png';
67
-        $this->sPathWhite = "$tmpDir/{$this->sNameWhite}";
68
-        $this->sSizeWhite = filesize($sSrcWhite);
69
-        // Copy the file to the temp dir.
70
-        @copy($sSrcWhite, $this->sPathWhite);
71
-
72
-        $sSrcBlue = __DIR__ . '/../upload/src/blue.png';
73
-        $this->sNameBlue = 'blue.png';
74
-        $this->sPathBlue = "$tmpDir/{$this->sNameBlue}";
75
-        $this->sSizeBlue = filesize($sSrcBlue);
76
-        // Copy the file to the temp dir.
77
-        @copy($sSrcBlue, $this->sPathBlue);
78
-    }
79
-
80
-    /**
55
+public function setUp(): void
56
+{
57
+jaxon()->di()->getPluginManager()->registerPlugins();
58
+jaxon()->setOption('core.response.send', false);
59
+jaxon()->setOption('upload.default.dir', __DIR__ . '/../upload/dst');
60
+_register();
61
+
62
+$tmpDir = __DIR__ . '/../upload/tmp';
63
+@mkdir($tmpDir);
64
+
65
+$sSrcWhite = __DIR__ . '/../upload/src/white.png';
66
+$this->sNameWhite = 'white.png';
67
+$this->sPathWhite = "$tmpDir/{$this->sNameWhite}";
68
+$this->sSizeWhite = filesize($sSrcWhite);
69
+// Copy the file to the temp dir.
70
+@copy($sSrcWhite, $this->sPathWhite);
71
+
72
+$sSrcBlue = __DIR__ . '/../upload/src/blue.png';
73
+$this->sNameBlue = 'blue.png';
74
+$this->sPathBlue = "$tmpDir/{$this->sNameBlue}";
75
+$this->sSizeBlue = filesize($sSrcBlue);
76
+// Copy the file to the temp dir.
77
+@copy($sSrcBlue, $this->sPathBlue);
78
+}
79
+
80
+/**
81 81
      * @throws SetupException
82 82
      */
83
-    public function tearDown(): void
84
-    {
85
-        jaxon()->reset();
86
-        parent::tearDown();
87
-    }
83
+public function tearDown(): void
84
+{
85
+jaxon()->reset();
86
+parent::tearDown();
87
+}
88 88
 
89
-    /**
89
+/**
90 90
      * @throws RequestException
91 91
      */
92
-    public function testHttpUploadDisabled()
93
-    {
94
-        jaxon()->setOption('core.upload.enabled', false);
95
-        jaxon()->register(Jaxon::CALLABLE_CLASS, 'SampleUpload', __DIR__ . '/../src/sample.php');
96
-
97
-        // Send a request to the registered class
98
-        jaxon()->di()->set(ServerRequestInterface::class, function($c) {
99
-            return $c->g(ServerRequestCreator::class)
100
-                ->fromGlobals()
101
-                ->withUploadedFiles([
102
-                    'image' => new UploadedFile($this->sPathWhite, $this->sSizeWhite,
103
-                        UPLOAD_ERR_OK, $this->sNameWhite, 'png'),
104
-                ])
105
-                ->withMethod('POST');
106
-        });
107
-
108
-        $this->assertFalse(jaxon()->di()->getRequestHandler()->canProcessRequest());
109
-    }
110
-
111
-    /**
92
+public function testHttpUploadDisabled()
93
+{
94
+jaxon()->setOption('core.upload.enabled', false);
95
+jaxon()->register(Jaxon::CALLABLE_CLASS, 'SampleUpload', __DIR__ . '/../src/sample.php');
96
+
97
+// Send a request to the registered class
98
+jaxon()->di()->set(ServerRequestInterface::class, function($c) {
99
+return $c->g(ServerRequestCreator::class)
100
+    ->fromGlobals()
101
+    ->withUploadedFiles([
102
+        'image' => new UploadedFile($this->sPathWhite, $this->sSizeWhite,
103
+            UPLOAD_ERR_OK, $this->sNameWhite, 'png'),
104
+    ])
105
+    ->withMethod('POST');
106
+});
107
+
108
+$this->assertFalse(jaxon()->di()->getRequestHandler()->canProcessRequest());
109
+}
110
+
111
+/**
112 112
      * @throws RequestException
113 113
      */
114
-    public function testRequestWithNoPluginNoUpload()
115
-    {
116
-        jaxon()->setOption('core.upload.enabled', false);
117
-        jaxon()->register(Jaxon::CALLABLE_CLASS, 'SampleUpload', __DIR__ . '/../src/sample.php');
118
-
119
-        // Send a request to the registered class
120
-        jaxon()->di()->set(ServerRequestInterface::class, function($c) {
121
-            return $c->g(ServerRequestCreator::class)
122
-                ->fromGlobals()
123
-                ->withParsedBody([
124
-                    'jxncall' => json_encode([
125
-                        'who' => 'Nobody',
126
-                        'args' => [],
127
-                    ]),
128
-                ])
129
-                ->withMethod('POST');
130
-        });
131
-
132
-        $this->assertFalse(jaxon()->di()->getRequestHandler()->canProcessRequest());
133
-    }
134
-
135
-    /**
114
+public function testRequestWithNoPluginNoUpload()
115
+{
116
+jaxon()->setOption('core.upload.enabled', false);
117
+jaxon()->register(Jaxon::CALLABLE_CLASS, 'SampleUpload', __DIR__ . '/../src/sample.php');
118
+
119
+// Send a request to the registered class
120
+jaxon()->di()->set(ServerRequestInterface::class, function($c) {
121
+return $c->g(ServerRequestCreator::class)
122
+    ->fromGlobals()
123
+    ->withParsedBody([
124
+        'jxncall' => json_encode([
125
+            'who' => 'Nobody',
126
+            'args' => [],
127
+        ]),
128
+    ])
129
+    ->withMethod('POST');
130
+});
131
+
132
+$this->assertFalse(jaxon()->di()->getRequestHandler()->canProcessRequest());
133
+}
134
+
135
+/**
136 136
      * @throws RequestException
137 137
      */
138
-    public function testUploadInMemoryStorage()
139
-    {
140
-        jaxon()->setOption('core.upload.enabled', true);
141
-        jaxon()->setOption('upload.default.storage', 'memory');
142
-        jaxon()->register(Jaxon::CALLABLE_CLASS, 'SampleUpload', __DIR__ . '/../src/sample.php');
143
-
144
-        // In memory file system adapter
145
-        jaxon()->upload()->registerStorageAdapter('memory',
146
-            fn() => new InMemoryFilesystemAdapter());
147
-
148
-        // Send a request to the registered class
149
-        jaxon()->di()->set(ServerRequestInterface::class, function($c) {
150
-            return $c->g(ServerRequestCreator::class)
151
-                ->fromGlobals()
152
-                ->withParsedBody([
153
-                    'jxncall' => json_encode([
154
-                        'type' => 'class',
155
-                        'name' => 'SampleUpload',
156
-                        'method' => 'myMethod',
157
-                        'args' => [],
158
-                    ]),
159
-                ])
160
-                ->withUploadedFiles([
161
-                    'image' => new UploadedFile($this->sPathWhite, $this->sSizeWhite,
162
-                        UPLOAD_ERR_OK, $this->sNameWhite, 'png'),
163
-                ])
164
-                ->withMethod('POST');
165
-        });
166
-
167
-        $this->assertTrue(jaxon()->di()->getRequestHandler()->canProcessRequest());
168
-        $this->assertTrue(jaxon()->di()->getUploadHandler()->canProcessRequest(jaxon()->di()->getRequest()));
169
-        jaxon()->processRequest();
170
-
171
-        // Uploaded files
172
-        $aFiles = jaxon()->upload()->files();
173
-        $this->assertCount(1, $aFiles);
174
-        $this->assertCount(1, $aFiles['image']);
175
-        $xFile = $aFiles['image'][0];
176
-        $this->assertEquals('white', $xFile->name());
177
-        $this->assertEquals($this->sNameWhite, $xFile->filename());
178
-        $this->assertEquals('png', $xFile->type());
179
-        $this->assertEquals('png', $xFile->extension());
180
-    }
138
+public function testUploadInMemoryStorage()
139
+{
140
+jaxon()->setOption('core.upload.enabled', true);
141
+jaxon()->setOption('upload.default.storage', 'memory');
142
+jaxon()->register(Jaxon::CALLABLE_CLASS, 'SampleUpload', __DIR__ . '/../src/sample.php');
143
+
144
+// In memory file system adapter
145
+jaxon()->upload()->registerStorageAdapter('memory',
146
+fn() => new InMemoryFilesystemAdapter());
147
+
148
+// Send a request to the registered class
149
+jaxon()->di()->set(ServerRequestInterface::class, function($c) {
150
+return $c->g(ServerRequestCreator::class)
151
+    ->fromGlobals()
152
+    ->withParsedBody([
153
+        'jxncall' => json_encode([
154
+            'type' => 'class',
155
+            'name' => 'SampleUpload',
156
+            'method' => 'myMethod',
157
+            'args' => [],
158
+        ]),
159
+    ])
160
+    ->withUploadedFiles([
161
+        'image' => new UploadedFile($this->sPathWhite, $this->sSizeWhite,
162
+            UPLOAD_ERR_OK, $this->sNameWhite, 'png'),
163
+    ])
164
+    ->withMethod('POST');
165
+});
166
+
167
+$this->assertTrue(jaxon()->di()->getRequestHandler()->canProcessRequest());
168
+$this->assertTrue(jaxon()->di()->getUploadHandler()->canProcessRequest(jaxon()->di()->getRequest()));
169
+jaxon()->processRequest();
170
+
171
+// Uploaded files
172
+$aFiles = jaxon()->upload()->files();
173
+$this->assertCount(1, $aFiles);
174
+$this->assertCount(1, $aFiles['image']);
175
+$xFile = $aFiles['image'][0];
176
+$this->assertEquals('white', $xFile->name());
177
+$this->assertEquals($this->sNameWhite, $xFile->filename());
178
+$this->assertEquals('png', $xFile->type());
179
+$this->assertEquals('png', $xFile->extension());
180
+}
181 181
 }
Please login to merge, or discard this patch.
jaxon-upload/src/Manager/FileStorage.php 2 patches
Switch Indentation   +110 added lines, -110 removed lines patch added patch discarded remove patch
@@ -28,146 +28,146 @@
 block discarded – undo
28 28
 
29 29
 class FileStorage
30 30
 {
31
-    /**
31
+/**
32 32
      * @var ConfigManager
33 33
      */
34
-    protected $xConfigManager;
34
+protected $xConfigManager;
35 35
 
36
-    /**
36
+/**
37 37
      * @var Translator
38 38
      */
39
-    protected $xTranslator;
39
+protected $xTranslator;
40 40
 
41
-    /**
41
+/**
42 42
      * @var array
43 43
      */
44
-    protected $aAdapters = [];
44
+protected $aAdapters = [];
45 45
 
46
-    /**
46
+/**
47 47
      * @var array
48 48
      */
49
-    protected $aFilesystems = [];
49
+protected $aFilesystems = [];
50 50
 
51
-    /**
51
+/**
52 52
      * The constructor
53 53
      *
54 54
      * @param ConfigManager $xConfigManager
55 55
      * @param Translator $xTranslator
56 56
      */
57
-    public function __construct(ConfigManager $xConfigManager, Translator $xTranslator)
58
-    {
59
-        $this->xConfigManager = $xConfigManager;
60
-        $this->xTranslator = $xTranslator;
61
-        $this->registerAdapters();
62
-    }
63
-
64
-    /**
57
+public function __construct(ConfigManager $xConfigManager, Translator $xTranslator)
58
+{
59
+$this->xConfigManager = $xConfigManager;
60
+$this->xTranslator = $xTranslator;
61
+$this->registerAdapters();
62
+}
63
+
64
+/**
65 65
      * @param string $sStorage
66 66
      * @param Closure $cFactory
67 67
      *
68 68
      * @return void
69 69
      */
70
-    public function registerAdapter(string $sStorage, Closure $cFactory)
71
-    {
72
-        $this->aAdapters[$sStorage] = $cFactory;
73
-    }
70
+public function registerAdapter(string $sStorage, Closure $cFactory)
71
+{
72
+$this->aAdapters[$sStorage] = $cFactory;
73
+}
74 74
 
75
-    /**
75
+/**
76 76
      * Register the file storage adapters
77 77
      *
78 78
      * @return void
79 79
      */
80
-    private function registerAdapters()
81
-    {
82
-        // Local file system adapter
83
-        $this->registerAdapter('local', function(string $sRootDir, $xOptions) {
84
-            return empty($xOptions) ? new LocalFilesystemAdapter($sRootDir) :
85
-                new LocalFilesystemAdapter($sRootDir, $xOptions);
86
-        });
87
-
88
-        // AWS S3 file system adapter
89
-        $this->registerAdapter('aws-s3', function(string $sRootDir, array $aOptions) {
90
-            /** @var \Aws\S3\S3ClientInterface $client */
91
-            $client = new \Aws\S3\S3Client($aOptions['client'] ?? []);
92
-            return new \League\Flysystem\AwsS3V3\AwsS3V3Adapter($client, $aOptions['bucket'] ?? '', $sRootDir);
93
-        });
94
-
95
-        // Async AWS S3 file system adapter
96
-        $this->registerAdapter('async-aws-s3', function(string $sRootDir, array $aOptions) {
97
-            $client = isset($aOptions['client']) ? new \AsyncAws\S3\S3Client($aOptions['client']) : new \AsyncAws\S3\S3Client();
98
-            return new \League\Flysystem\AsyncAwsS3\AsyncAwsS3Adapter($client, $aOptions['bucket'] ?? '', $sRootDir);
99
-        });
100
-
101
-        // Google Cloud file system adapter
102
-        $this->registerAdapter('google-cloud', function(string $sRootDir, array $aOptions) {
103
-            $storageClient = new \Google\Cloud\Storage\StorageClient($aOptions['client'] ?? []);
104
-            $bucket = $storageClient->bucket($aOptions['bucket'] ?? '');
105
-            return new \League\Flysystem\AzureBlobStorage\GoogleCloudStorageAdapter($bucket, $sRootDir);
106
-        });
107
-
108
-        // Microsoft Azure file system adapter
109
-        $this->registerAdapter('azure-blob', function(string $sRootDir, array $aOptions) {
110
-            $client = \MicrosoftAzure\Storage\Blob\BlobRestProxy::createBlobService($aOptions['dsn']);
111
-            return new \League\Flysystem\AzureBlobStorage\AzureBlobStorageAdapter($client, $aOptions['container'], $sRootDir);
112
-        });
113
-
114
-        // FTP file system adapter
115
-        $this->registerAdapter('ftp', function(string $sRootDir, array $aOptions) {
116
-            $aOptions['root'] = $sRootDir;
117
-            $xOptions = \League\Flysystem\Ftp\FtpConnectionOptions::fromArray($aOptions);
118
-            return new \League\Flysystem\Ftp\FtpAdapter($xOptions);
119
-        });
120
-
121
-        // SFTP V2 file system adapter
122
-        $this->registerAdapter('sftp-v2', function(string $sRootDir, array $aOptions) {
123
-            $provider = new \League\Flysystem\PhpseclibV2\SftpConnectionProvider(...$aOptions);
124
-            return new \League\Flysystem\PhpseclibV2\SftpAdapter($provider, $sRootDir);
125
-        });
126
-
127
-        // SFTP V3 file system adapter
128
-        $this->registerAdapter('sftp-v3', function(string $sRootDir, array $aOptions) {
129
-            $provider = new \League\Flysystem\PhpseclibV3\SftpConnectionProvider(...$aOptions);
130
-            return new \League\Flysystem\PhpseclibV3\SftpAdapter($provider, $sRootDir);
131
-        });
132
-    }
133
-
134
-    /**
80
+private function registerAdapters()
81
+{
82
+// Local file system adapter
83
+$this->registerAdapter('local', function(string $sRootDir, $xOptions) {
84
+return empty($xOptions) ? new LocalFilesystemAdapter($sRootDir) :
85
+    new LocalFilesystemAdapter($sRootDir, $xOptions);
86
+});
87
+
88
+// AWS S3 file system adapter
89
+$this->registerAdapter('aws-s3', function(string $sRootDir, array $aOptions) {
90
+/** @var \Aws\S3\S3ClientInterface $client */
91
+$client = new \Aws\S3\S3Client($aOptions['client'] ?? []);
92
+return new \League\Flysystem\AwsS3V3\AwsS3V3Adapter($client, $aOptions['bucket'] ?? '', $sRootDir);
93
+});
94
+
95
+// Async AWS S3 file system adapter
96
+$this->registerAdapter('async-aws-s3', function(string $sRootDir, array $aOptions) {
97
+$client = isset($aOptions['client']) ? new \AsyncAws\S3\S3Client($aOptions['client']) : new \AsyncAws\S3\S3Client();
98
+return new \League\Flysystem\AsyncAwsS3\AsyncAwsS3Adapter($client, $aOptions['bucket'] ?? '', $sRootDir);
99
+});
100
+
101
+// Google Cloud file system adapter
102
+$this->registerAdapter('google-cloud', function(string $sRootDir, array $aOptions) {
103
+$storageClient = new \Google\Cloud\Storage\StorageClient($aOptions['client'] ?? []);
104
+$bucket = $storageClient->bucket($aOptions['bucket'] ?? '');
105
+return new \League\Flysystem\AzureBlobStorage\GoogleCloudStorageAdapter($bucket, $sRootDir);
106
+});
107
+
108
+// Microsoft Azure file system adapter
109
+$this->registerAdapter('azure-blob', function(string $sRootDir, array $aOptions) {
110
+$client = \MicrosoftAzure\Storage\Blob\BlobRestProxy::createBlobService($aOptions['dsn']);
111
+return new \League\Flysystem\AzureBlobStorage\AzureBlobStorageAdapter($client, $aOptions['container'], $sRootDir);
112
+});
113
+
114
+// FTP file system adapter
115
+$this->registerAdapter('ftp', function(string $sRootDir, array $aOptions) {
116
+$aOptions['root'] = $sRootDir;
117
+$xOptions = \League\Flysystem\Ftp\FtpConnectionOptions::fromArray($aOptions);
118
+return new \League\Flysystem\Ftp\FtpAdapter($xOptions);
119
+});
120
+
121
+// SFTP V2 file system adapter
122
+$this->registerAdapter('sftp-v2', function(string $sRootDir, array $aOptions) {
123
+$provider = new \League\Flysystem\PhpseclibV2\SftpConnectionProvider(...$aOptions);
124
+return new \League\Flysystem\PhpseclibV2\SftpAdapter($provider, $sRootDir);
125
+});
126
+
127
+// SFTP V3 file system adapter
128
+$this->registerAdapter('sftp-v3', function(string $sRootDir, array $aOptions) {
129
+$provider = new \League\Flysystem\PhpseclibV3\SftpConnectionProvider(...$aOptions);
130
+return new \League\Flysystem\PhpseclibV3\SftpAdapter($provider, $sRootDir);
131
+});
132
+}
133
+
134
+/**
135 135
      * @param string $sField
136 136
      *
137 137
      * @return Filesystem
138 138
      * @throws RequestException
139 139
      */
140
-    public function filesystem(string $sField = ''): Filesystem
141
-    {
142
-        $sField = trim($sField);
143
-        if(isset($this->aFilesystems[$sField]))
144
-        {
145
-            return $this->aFilesystems[$sField];
146
-        }
147
-
148
-        // Default upload dir
149
-        $sStorage = $this->xConfigManager->getOption('upload.default.storage', 'local');
150
-        $sRootDir = $this->xConfigManager->getOption('upload.default.dir', '');
151
-        $aOptions = $this->xConfigManager->getOption('upload.default.options');
152
-        $sConfigKey = "upload.files.$sField";
153
-        if($sField !== '' && $this->xConfigManager->hasOption($sConfigKey))
154
-        {
155
-            $sStorage = $this->xConfigManager->getOption("$sConfigKey.storage", $sStorage);
156
-            $sRootDir = $this->xConfigManager->getOption("$sConfigKey.dir", $sRootDir);
157
-            $aOptions = $this->xConfigManager->getOption("$sConfigKey.options", $aOptions);
158
-        }
159
-
160
-        if(!is_string($sRootDir))
161
-        {
162
-            throw new RequestException($this->xTranslator->trans('errors.upload.dir'));
163
-        }
164
-        if(!isset($this->aAdapters[$sStorage]))
165
-        {
166
-            throw new RequestException($this->xTranslator->trans('errors.upload.adapter'));
167
-        }
168
-
169
-        $xAdapter = call_user_func($this->aAdapters[$sStorage], $sRootDir, $aOptions);
170
-        $this->aFilesystems[$sField] = new Filesystem($xAdapter);
171
-        return $this->aFilesystems[$sField];
172
-    }
140
+public function filesystem(string $sField = ''): Filesystem
141
+{
142
+$sField = trim($sField);
143
+if(isset($this->aFilesystems[$sField]))
144
+{
145
+return $this->aFilesystems[$sField];
146
+}
147
+
148
+// Default upload dir
149
+$sStorage = $this->xConfigManager->getOption('upload.default.storage', 'local');
150
+$sRootDir = $this->xConfigManager->getOption('upload.default.dir', '');
151
+$aOptions = $this->xConfigManager->getOption('upload.default.options');
152
+$sConfigKey = "upload.files.$sField";
153
+if($sField !== '' && $this->xConfigManager->hasOption($sConfigKey))
154
+{
155
+$sStorage = $this->xConfigManager->getOption("$sConfigKey.storage", $sStorage);
156
+$sRootDir = $this->xConfigManager->getOption("$sConfigKey.dir", $sRootDir);
157
+$aOptions = $this->xConfigManager->getOption("$sConfigKey.options", $aOptions);
158
+}
159
+
160
+if(!is_string($sRootDir))
161
+{
162
+throw new RequestException($this->xTranslator->trans('errors.upload.dir'));
163
+}
164
+if(!isset($this->aAdapters[$sStorage]))
165
+{
166
+throw new RequestException($this->xTranslator->trans('errors.upload.adapter'));
167
+}
168
+
169
+$xAdapter = call_user_func($this->aAdapters[$sStorage], $sRootDir, $aOptions);
170
+$this->aFilesystems[$sField] = new Filesystem($xAdapter);
171
+return $this->aFilesystems[$sField];
172
+}
173 173
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -6 removed lines patch added patch discarded remove patch
@@ -81,8 +81,7 @@  discard block
 block discarded – undo
81 81
     {
82 82
         // Local file system adapter
83 83
         $this->registerAdapter('local', function(string $sRootDir, $xOptions) {
84
-            return empty($xOptions) ? new LocalFilesystemAdapter($sRootDir) :
85
-                new LocalFilesystemAdapter($sRootDir, $xOptions);
84
+            return empty($xOptions) ? new LocalFilesystemAdapter($sRootDir) : new LocalFilesystemAdapter($sRootDir, $xOptions);
86 85
         });
87 86
 
88 87
         // AWS S3 file system adapter
@@ -140,7 +139,7 @@  discard block
 block discarded – undo
140 139
     public function filesystem(string $sField = ''): Filesystem
141 140
     {
142 141
         $sField = trim($sField);
143
-        if(isset($this->aFilesystems[$sField]))
142
+        if (isset($this->aFilesystems[$sField]))
144 143
         {
145 144
             return $this->aFilesystems[$sField];
146 145
         }
@@ -150,18 +149,18 @@  discard block
 block discarded – undo
150 149
         $sRootDir = $this->xConfigManager->getOption('upload.default.dir', '');
151 150
         $aOptions = $this->xConfigManager->getOption('upload.default.options');
152 151
         $sConfigKey = "upload.files.$sField";
153
-        if($sField !== '' && $this->xConfigManager->hasOption($sConfigKey))
152
+        if ($sField !== '' && $this->xConfigManager->hasOption($sConfigKey))
154 153
         {
155 154
             $sStorage = $this->xConfigManager->getOption("$sConfigKey.storage", $sStorage);
156 155
             $sRootDir = $this->xConfigManager->getOption("$sConfigKey.dir", $sRootDir);
157 156
             $aOptions = $this->xConfigManager->getOption("$sConfigKey.options", $aOptions);
158 157
         }
159 158
 
160
-        if(!is_string($sRootDir))
159
+        if (!is_string($sRootDir))
161 160
         {
162 161
             throw new RequestException($this->xTranslator->trans('errors.upload.dir'));
163 162
         }
164
-        if(!isset($this->aAdapters[$sStorage]))
163
+        if (!isset($this->aAdapters[$sStorage]))
165 164
         {
166 165
             throw new RequestException($this->xTranslator->trans('errors.upload.adapter'));
167 166
         }
Please login to merge, or discard this patch.
jaxon-core/src/Di/Traits/ComponentTrait.php 1 patch
Spacing   +14 added lines, -15 removed lines patch added patch discarded remove patch
@@ -144,15 +144,15 @@  discard block
 block discarded – undo
144 144
         $xRegistry->updateHash(false); // Disable hash calculation.
145 145
 
146 146
         $sComponentId = str_replace('\\', '.', $sClassName);
147
-        if(!isset($this->aComponents[$sComponentId]))
147
+        if (!isset($this->aComponents[$sComponentId]))
148 148
         {
149 149
             $aOptions = $xRegistry->getNamespaceComponentOptions($sClassName);
150
-            if($aOptions !== null)
150
+            if ($aOptions !== null)
151 151
             {
152 152
                 $this->saveComponent($sClassName, $aOptions);
153 153
             }
154 154
         }
155
-        if(isset($this->aComponents[$sComponentId]))
155
+        if (isset($this->aComponents[$sComponentId]))
156 156
         {
157 157
             return; // The component is found.
158 158
         }
@@ -160,11 +160,11 @@  discard block
 block discarded – undo
160 160
         // The component was not found in a registered namespace. We need to parse all
161 161
         // the directories to be able to find a component registered without a namespace.
162 162
         $sComponentId = str_replace('\\', '_', $sClassName);
163
-        if(!isset($this->aComponents[$sComponentId]))
163
+        if (!isset($this->aComponents[$sComponentId]))
164 164
         {
165 165
             $xRegistry->registerComponentsInDirectories();
166 166
         }
167
-        if(isset($this->aComponents[$sComponentId]))
167
+        if (isset($this->aComponents[$sComponentId]))
168 168
         {
169 169
             return; // The component is found.
170 170
         }
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
     public function getCallableObjects(): array
183 183
     {
184 184
         $aCallableObjects = [];
185
-        foreach($this->aComponents as $sComponentId => $_)
185
+        foreach ($this->aComponents as $sComponentId => $_)
186 186
         {
187 187
             $aCallableObjects[$sComponentId] = $this->makeCallableObject($sComponentId);
188 188
         }
@@ -233,12 +233,12 @@  discard block
 block discarded – undo
233 233
     {
234 234
         /** @var Config|null */
235 235
         $xPackageConfig = $aOptions['config'] ?? null;
236
-        if($xPackageConfig === null || (bool)($aOptions['excluded'] ?? false))
236
+        if ($xPackageConfig === null || (bool)($aOptions['excluded'] ?? false))
237 237
         {
238 238
             return null;
239 239
         }
240 240
         $sMetadataFormat = $xPackageConfig->getOption('metadata.format');
241
-        if(!in_array($sMetadataFormat, ['attributes', 'annotations']))
241
+        if (!in_array($sMetadataFormat, ['attributes', 'annotations']))
242 242
         {
243 243
             return null;
244 244
         }
@@ -248,23 +248,23 @@  discard block
 block discarded – undo
248 248
         $xMetadata = null;
249 249
         $xMetadataCache = null;
250 250
         $xConfig = $di->config();
251
-        if($xConfig->getAppOption('metadata.cache.enabled', false))
251
+        if ($xConfig->getAppOption('metadata.cache.enabled', false))
252 252
         {
253
-            if(!$di->h('jaxon_metadata_cache_dir'))
253
+            if (!$di->h('jaxon_metadata_cache_dir'))
254 254
             {
255 255
                 $sCacheDir = $xConfig->getAppOption('metadata.cache.dir');
256 256
                 $di->val('jaxon_metadata_cache_dir', $sCacheDir);
257 257
             }
258 258
             $xMetadataCache = $di->getMetadataCache();
259 259
             $xMetadata = $xMetadataCache->read($xReflectionClass->getName());
260
-            if($xMetadata !== null)
260
+            if ($xMetadata !== null)
261 261
             {
262 262
                 return $xMetadata;
263 263
             }
264 264
         }
265 265
 
266 266
         $aProperties = array_map(fn($xProperty) => $xProperty->getName(),
267
-            $xReflectionClass->getProperties(ReflectionProperty::IS_PUBLIC |
267
+            $xReflectionClass->getProperties(ReflectionProperty::IS_PUBLIC|
268 268
                 ReflectionProperty::IS_PROTECTED));
269 269
         $aMethods = $this->getPublicMethods($xReflectionClass);
270 270
 
@@ -273,7 +273,7 @@  discard block
 block discarded – undo
273 273
         $xMetadata = $xMetadataReader->getAttributes($xInput);
274 274
 
275 275
         // Try to save the metadata in the cache
276
-        if($xMetadataCache !== null && $xMetadata !== null)
276
+        if ($xMetadataCache !== null && $xMetadata !== null)
277 277
         {
278 278
             $xMetadataCache->save($xReflectionClass->getName(), $xMetadata);
279 279
         }
@@ -291,8 +291,7 @@  discard block
 block discarded – undo
291 291
         array $aOptions): ComponentOptions
292 292
     {
293 293
         $xMetadata = $this->getComponentMetadata($xReflectionClass, $aOptions);
294
-        return !$xMetadata ? new ComponentOptions($aOptions) :
295
-            new ComponentOptions($aOptions, $xMetadata->isExcluded(),
294
+        return !$xMetadata ? new ComponentOptions($aOptions) : new ComponentOptions($aOptions, $xMetadata->isExcluded(),
296 295
             $xMetadata->getProtectedMethods(), $xMetadata->getProperties());
297 296
     }
298 297
 }
Please login to merge, or discard this patch.
jaxon-core/src/Jaxon.php 1 patch
Switch Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -16,23 +16,23 @@
 block discarded – undo
16 16
 
17 17
 class Jaxon
18 18
 {
19
-    /**
19
+/**
20 20
      * @const string
21 21
      */
22
-    public const VERSION = 'Jaxon 5.x';
22
+public const VERSION = 'Jaxon 5.x';
23 23
 
24
-    /**
24
+/**
25 25
      * @const string
26 26
      */
27
-    public const CALLABLE_CLASS = 'CallableClass';
27
+public const CALLABLE_CLASS = 'CallableClass';
28 28
 
29
-    /**
29
+/**
30 30
      * @const string
31 31
      */
32
-    public const CALLABLE_DIR = 'CallableDir';
32
+public const CALLABLE_DIR = 'CallableDir';
33 33
 
34
-    /**
34
+/**
35 35
      * @const string
36 36
      */
37
-    public const CALLABLE_FUNCTION = 'CallableFunction';
37
+public const CALLABLE_FUNCTION = 'CallableFunction';
38 38
 }
Please login to merge, or discard this patch.
jaxon-core/src/Request/Target.php 1 patch
Switch Indentation   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -17,56 +17,56 @@  discard block
 block discarded – undo
17 17
 
18 18
 class Target implements TargetInterface
19 19
 {
20
-    /**
20
+/**
21 21
      * The target type for function.
22 22
      *
23 23
      * @var string
24 24
      */
25
-    const TYPE_FUNCTION = 'TargetFunction';
25
+const TYPE_FUNCTION = 'TargetFunction';
26 26
 
27
-    /**
27
+/**
28 28
      * The target type for class.
29 29
      *
30 30
      * @var string
31 31
      */
32
-    const TYPE_CLASS = 'TargetClass';
32
+const TYPE_CLASS = 'TargetClass';
33 33
 
34
-    /**
34
+/**
35 35
      * The target type.
36 36
      *
37 37
      * @var string
38 38
      */
39
-    private $sType = '';
39
+private $sType = '';
40 40
 
41
-    /**
41
+/**
42 42
      * The target function name.
43 43
      *
44 44
      * @var string
45 45
      */
46
-    private $sFunctionName = '';
46
+private $sFunctionName = '';
47 47
 
48
-    /**
48
+/**
49 49
      * The target class name.
50 50
      *
51 51
      * @var string
52 52
      */
53
-    private $sClassName = '';
53
+private $sClassName = '';
54 54
 
55
-    /**
55
+/**
56 56
      * The target method name.
57 57
      *
58 58
      * @var string
59 59
      */
60
-    private $sMethodName = '';
60
+private $sMethodName = '';
61 61
 
62
-    /**
62
+/**
63 63
      * The target method args.
64 64
      *
65 65
      * @var array
66 66
      */
67
-    private $aMethodArgs = [];
67
+private $aMethodArgs = [];
68 68
 
69
-    /**
69
+/**
70 70
      * The constructor
71 71
      *
72 72
      * @param string $sType    The target type
@@ -75,116 +75,116 @@  discard block
 block discarded – undo
75 75
      * @param string $sMethodName    The method name
76 76
      * @param array $aMethodArgs    The method args
77 77
      */
78
-    private function __construct(string $sType, string $sFunctionName, string $sClassName, string $sMethodName, array $aMethodArgs = [])
79
-    {
80
-        $this->sType = $sType;
81
-        $this->sFunctionName = $sFunctionName;
82
-        $this->sClassName = $sClassName;
83
-        $this->sMethodName = $sMethodName;
84
-        $this->aMethodArgs = $aMethodArgs;
85
-    }
78
+private function __construct(string $sType, string $sFunctionName, string $sClassName, string $sMethodName, array $aMethodArgs = [])
79
+{
80
+$this->sType = $sType;
81
+$this->sFunctionName = $sFunctionName;
82
+$this->sClassName = $sClassName;
83
+$this->sMethodName = $sMethodName;
84
+$this->aMethodArgs = $aMethodArgs;
85
+}
86 86
 
87
-    /**
87
+/**
88 88
      * Create a target of type Function
89 89
      *
90 90
      * @param string $sFunctionName    The function name
91 91
      *
92 92
      * @return Target
93 93
      */
94
-    public static function makeFunction(string $sFunctionName): Target
95
-    {
96
-        return new Target(self::TYPE_FUNCTION, $sFunctionName, '', '');
97
-    }
94
+public static function makeFunction(string $sFunctionName): Target
95
+{
96
+return new Target(self::TYPE_FUNCTION, $sFunctionName, '', '');
97
+}
98 98
 
99
-    /**
99
+/**
100 100
      * Create a target of type Class
101 101
      *
102 102
      * @param array $aCall
103 103
      *
104 104
      * @return Target
105 105
      */
106
-    public static function makeClass(array $aCall): Target
107
-    {
108
-        return new Target(self::TYPE_CLASS, '', trim($aCall['name']), trim($aCall['method']));
109
-    }
106
+public static function makeClass(array $aCall): Target
107
+{
108
+return new Target(self::TYPE_CLASS, '', trim($aCall['name']), trim($aCall['method']));
109
+}
110 110
 
111
-    /**
111
+/**
112 112
      * Check if the target type is Function.
113 113
      *
114 114
      * @return bool
115 115
      */
116
-    public function isFunction(): bool
117
-    {
118
-        return $this->sType === self::TYPE_FUNCTION;
119
-    }
116
+public function isFunction(): bool
117
+{
118
+return $this->sType === self::TYPE_FUNCTION;
119
+}
120 120
 
121
-    /**
121
+/**
122 122
      * Check if the target type is Class.
123 123
      *
124 124
      * @return bool
125 125
      */
126
-    public function isClass(): bool
127
-    {
128
-        return $this->sType === self::TYPE_CLASS;
129
-    }
126
+public function isClass(): bool
127
+{
128
+return $this->sType === self::TYPE_CLASS;
129
+}
130 130
 
131
-    /**
131
+/**
132 132
      * The target function name.
133 133
      *
134 134
      * @return string
135 135
      */
136
-    public function getFunctionName(): string
137
-    {
138
-        return $this->sFunctionName;
139
-    }
136
+public function getFunctionName(): string
137
+{
138
+return $this->sFunctionName;
139
+}
140 140
 
141
-    /**
141
+/**
142 142
      * The target class name.
143 143
      *
144 144
      * @return string
145 145
      */
146
-    public function getClassName(): string
147
-    {
148
-        return $this->sClassName;
149
-    }
146
+public function getClassName(): string
147
+{
148
+return $this->sClassName;
149
+}
150 150
 
151
-    /**
151
+/**
152 152
      * The target method name.
153 153
      *
154 154
      * @return string
155 155
      */
156
-    public function getMethodName(): string
157
-    {
158
-        return $this->sMethodName;
159
-    }
156
+public function getMethodName(): string
157
+{
158
+return $this->sMethodName;
159
+}
160 160
 
161
-    /**
161
+/**
162 162
      * Set the target method name.
163 163
      *
164 164
      * @param array $aMethodArgs
165 165
      */
166
-    public function setMethodArgs(array $aMethodArgs): void
167
-    {
168
-        $this->aMethodArgs = $aMethodArgs;
169
-    }
166
+public function setMethodArgs(array $aMethodArgs): void
167
+{
168
+$this->aMethodArgs = $aMethodArgs;
169
+}
170 170
 
171
-    /**
171
+/**
172 172
      * The target method name.
173 173
      *
174 174
      * @return string
175 175
      */
176
-    public function method(): string
177
-    {
178
-        return $this->sMethodName;
179
-    }
176
+public function method(): string
177
+{
178
+return $this->sMethodName;
179
+}
180 180
 
181
-    /**
181
+/**
182 182
      * The target method args.
183 183
      *
184 184
      * @return array
185 185
      */
186
-    public function args(): array
187
-    {
188
-        return $this->aMethodArgs;
189
-    }
186
+public function args(): array
187
+{
188
+return $this->aMethodArgs;
189
+}
190 190
 }
Please login to merge, or discard this patch.
jaxon-core/src/Plugin/Request/CallableClass/ComponentRegistry.php 1 patch
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
     public function __construct(protected ComponentContainer $cdi)
111 111
     {
112 112
         // Set the composer autoloader
113
-        if(file_exists(($sAutoloadFile = __DIR__ . '/../../../../../../autoload.php')) ||
113
+        if (file_exists(($sAutoloadFile = __DIR__ . '/../../../../../../autoload.php')) ||
114 114
             file_exists(($sAutoloadFile = __DIR__ . '/../../../../../vendor/autoload.php')) ||
115 115
             file_exists(($sAutoloadFile = __DIR__ . '/../../../../vendor/autoload.php')))
116 116
         {
@@ -179,15 +179,15 @@  discard block
 block discarded – undo
179 179
      */
180 180
     private function makeClassOptions(string $sClassName, array $aClassOptions, array $aDirectoryOptions): array
181 181
     {
182
-        foreach($this->aDefaultClassOptions as $sOption => $xValue)
182
+        foreach ($this->aDefaultClassOptions as $sOption => $xValue)
183 183
         {
184
-            if(!isset($aClassOptions[$sOption]))
184
+            if (!isset($aClassOptions[$sOption]))
185 185
             {
186 186
                 $aClassOptions[$sOption] = $xValue;
187 187
             }
188 188
         }
189 189
         $aClassOptions['excluded'] = (bool)($aClassOptions['excluded'] ?? false); // Convert to bool.
190
-        if(is_string($aClassOptions['protected']))
190
+        if (is_string($aClassOptions['protected']))
191 191
         {
192 192
             $aClassOptions['protected'] = [$aClassOptions['protected']]; // Convert to array.
193 193
         }
@@ -198,30 +198,30 @@  discard block
 block discarded – undo
198 198
             $aDirectoryOptions['classes']['*'] ?? [], // Options for all classes
199 199
             $aDirectoryOptions['classes'][$sClassName] ?? [], // Options for this specific class
200 200
         ];
201
-        foreach($aOptionGroups as $aOptionGroup)
201
+        foreach ($aOptionGroups as $aOptionGroup)
202 202
         {
203
-            if(isset($aOptionGroup['separator']))
203
+            if (isset($aOptionGroup['separator']))
204 204
             {
205 205
                 $aClassOptions['separator'] = (string)$aOptionGroup['separator'];
206 206
             }
207
-            if(isset($aOptionGroup['excluded']))
207
+            if (isset($aOptionGroup['excluded']))
208 208
             {
209 209
                 $aClassOptions['excluded'] = (bool)$aOptionGroup['excluded'];
210 210
             }
211
-            if(isset($aOptionGroup['protected']))
211
+            if (isset($aOptionGroup['protected']))
212 212
             {
213
-                if(is_string($aOptionGroup['protected']))
213
+                if (is_string($aOptionGroup['protected']))
214 214
                 {
215 215
                     $aOptionGroup['protected'] = [$aOptionGroup['protected']]; // Convert to array.
216 216
                 }
217 217
                 $aClassOptions['protected'] = array_merge($aClassOptions['protected'], $aOptionGroup['protected']);
218 218
             }
219
-            if(isset($aOptionGroup['functions']))
219
+            if (isset($aOptionGroup['functions']))
220 220
             {
221 221
                 $aClassOptions['functions'] = array_merge($aClassOptions['functions'], $aOptionGroup['functions']);
222 222
             }
223 223
         }
224
-        if(isset($aDirectoryOptions['config']) && !isset($aClassOptions['config']))
224
+        if (isset($aDirectoryOptions['config']) && !isset($aClassOptions['config']))
225 225
         {
226 226
             $aClassOptions['config'] = $aDirectoryOptions['config'];
227 227
         }
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
     {
244 244
         $aOptions = $this->makeClassOptions($sClassName, $aClassOptions, $aDirectoryOptions);
245 245
         $this->cdi->saveComponent($sClassName, $aOptions);
246
-        if($this->bUpdateHash)
246
+        if ($this->bUpdateHash)
247 247
         {
248 248
             $this->sHash .= $sClassName . $aOptions['timestamp'];
249 249
         }
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
     {
262 262
         // For classes, the underscore is used as separator.
263 263
         $aClassOptions['separator'] = '_';
264
-        if($this->xPackageConfig !== null)
264
+        if ($this->xPackageConfig !== null)
265 265
         {
266 266
             $aClassOptions['config'] = $this->xPackageConfig;
267 267
         }
@@ -278,10 +278,10 @@  discard block
 block discarded – undo
278 278
     public function getNamespaceComponentOptions(string $sClassName): ?array
279 279
     {
280 280
         // Find the corresponding namespace
281
-        foreach($this->aNamespaceOptions as $sNamespace => $aDirectoryOptions)
281
+        foreach ($this->aNamespaceOptions as $sNamespace => $aDirectoryOptions)
282 282
         {
283 283
             // Check if the namespace matches the class.
284
-            if(strncmp($sClassName, $sNamespace . '\\', strlen($sNamespace) + 1) === 0)
284
+            if (strncmp($sClassName, $sNamespace . '\\', strlen($sNamespace) + 1) === 0)
285 285
             {
286 286
                 // Save the class options
287 287
                 $aClassOptions = ['namespace' => $sNamespace];
@@ -304,11 +304,11 @@  discard block
 block discarded – undo
304 304
         // For directories without namespace, the underscore is used as separator.
305 305
         $aOptions['separator'] = '_';
306 306
         // Set the autoload option default value
307
-        if(!isset($aOptions['autoload']))
307
+        if (!isset($aOptions['autoload']))
308 308
         {
309 309
             $aOptions['autoload'] = true;
310 310
         }
311
-        if($this->xPackageConfig !== null)
311
+        if ($this->xPackageConfig !== null)
312 312
         {
313 313
             $aOptions['config'] = $this->xPackageConfig;
314 314
         }
@@ -342,16 +342,16 @@  discard block
 block discarded – undo
342 342
         // For namespaces, the dot is used as separator.
343 343
         $aOptions['separator'] = '.';
344 344
         // Set the autoload option default value
345
-        if(!isset($aOptions['autoload']))
345
+        if (!isset($aOptions['autoload']))
346 346
         {
347 347
             $aOptions['autoload'] = true;
348 348
         }
349
-        if($this->xPackageConfig !== null)
349
+        if ($this->xPackageConfig !== null)
350 350
         {
351 351
             $aOptions['config'] = $this->xPackageConfig;
352 352
         }
353 353
         // Register the dir with PSR4 autoloading
354
-        if(($aOptions['autoload']) && $this->xAutoloader != null)
354
+        if (($aOptions['autoload']) && $this->xAutoloader != null)
355 355
         {
356 356
             $this->xAutoloader->setPsr4($sNamespace . '\\', $aOptions['directory']);
357 357
         }
@@ -367,7 +367,7 @@  discard block
 block discarded – undo
367 367
     public function registerComponentsInNamespaces(): void
368 368
     {
369 369
         // This is to be done only once.
370
-        if($this->bNamespacesParsed)
370
+        if ($this->bNamespacesParsed)
371 371
         {
372 372
             return;
373 373
         }
@@ -375,17 +375,17 @@  discard block
 block discarded – undo
375 375
 
376 376
         // Browse directories with namespaces and read all the files.
377 377
         $sDS = DIRECTORY_SEPARATOR;
378
-        foreach($this->aNamespaceOptions as $sNamespace => $aDirectoryOptions)
378
+        foreach ($this->aNamespaceOptions as $sNamespace => $aDirectoryOptions)
379 379
         {
380 380
             $this->addNamespace($sNamespace, ['separator' => '.']);
381 381
 
382 382
             // Iterate on dir content
383 383
             $sDirectory = $aDirectoryOptions['directory'];
384 384
             $itFile = new SortedFileIterator($sDirectory);
385
-            foreach($itFile as $xFile)
385
+            foreach ($itFile as $xFile)
386 386
             {
387 387
                 // skip everything except PHP files
388
-                if(!$xFile->isFile() || $xFile->getExtension() !== 'php')
388
+                if (!$xFile->isFile() || $xFile->getExtension() !== 'php')
389 389
                 {
390 390
                     continue;
391 391
                 }
@@ -394,7 +394,7 @@  discard block
 block discarded – undo
394 394
                 $sClassPath = $sNamespace;
395 395
                 $sRelativePath = substr($xFile->getPath(), strlen($sDirectory));
396 396
                 $sRelativePath = trim(str_replace($sDS, '\\', $sRelativePath), '\\');
397
-                if($sRelativePath !== '')
397
+                if ($sRelativePath !== '')
398 398
                 {
399 399
                     $sClassPath .= '\\' . $sRelativePath;
400 400
                 }
@@ -420,21 +420,21 @@  discard block
 block discarded – undo
420 420
     public function registerComponentsInDirectories(): void
421 421
     {
422 422
         // This is to be done only once.
423
-        if($this->bDirectoriesParsed)
423
+        if ($this->bDirectoriesParsed)
424 424
         {
425 425
             return;
426 426
         }
427 427
         $this->bDirectoriesParsed = true;
428 428
 
429 429
         // Browse directories without namespaces and read all the files.
430
-        foreach($this->aDirectoryOptions as $sDirectory => $aDirectoryOptions)
430
+        foreach ($this->aDirectoryOptions as $sDirectory => $aDirectoryOptions)
431 431
         {
432 432
             $itFile = new SortedFileIterator($sDirectory);
433 433
             // Iterate on dir content
434
-            foreach($itFile as $xFile)
434
+            foreach ($itFile as $xFile)
435 435
             {
436 436
                 // Skip everything except PHP files
437
-                if(!$xFile->isFile() || $xFile->getExtension() !== 'php')
437
+                if (!$xFile->isFile() || $xFile->getExtension() !== 'php')
438 438
                 {
439 439
                     continue;
440 440
                 }
@@ -444,7 +444,7 @@  discard block
 block discarded – undo
444 444
                     'separator' => '.',
445 445
                     'timestamp' => $xFile->getMTime(),
446 446
                 ];
447
-                if(($aDirectoryOptions['autoload']) && $this->xAutoloader !== null)
447
+                if (($aDirectoryOptions['autoload']) && $this->xAutoloader !== null)
448 448
                 {
449 449
                     // Set classmap autoloading. Must be done before registering the class.
450 450
                     $this->xAutoloader->addClassMap([$sClassName => $xFile->getPathname()]);
Please login to merge, or discard this patch.
jaxon-core/templates/callables/method.js.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@
 block discarded – undo
1 1
 <?php echo $this->aMethod['name'] ?>: function() { return jaxon.request({ type: 'class', name: '<?php
2 2
     echo $this->sJsClass ?>', method: '<?php echo $this->aMethod['name']
3
-    ?>' }, { parameters: arguments<?php foreach($this->aMethod['options'] as $sKey => $sValue):
3
+    ?>' }, { parameters: arguments<?php foreach ($this->aMethod['options'] as $sKey => $sValue):
4 4
         ?>, <?php echo $sKey ?>: <?php echo $sValue ?><?php endforeach ?> }); },
Please login to merge, or discard this patch.