Completed
Push — master ( 331d03...c48bd4 )
by Thierry
01:44
created
src/Request/Support/CallableObject.php 2 patches
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -107,15 +107,15 @@  discard block
 block discarded – undo
107 107
     private function makeCallable()
108 108
     {
109 109
         // Create an instance of the registered class
110
-        if($this->callableObject == null)
110
+        if ($this->callableObject == null)
111 111
         {
112 112
             $di = jaxon()->di();
113 113
             // Use the Reflection class to get the parameters of the constructor
114
-            if(($constructor = $this->reflectionClass->getConstructor()) != null)
114
+            if (($constructor = $this->reflectionClass->getConstructor()) != null)
115 115
             {
116 116
                 $parameters = $constructor->getParameters();
117 117
                 $parameterInstances = [];
118
-                foreach($parameters as $parameter)
118
+                foreach ($parameters as $parameter)
119 119
                 {
120 120
                     // Get the parameter instance from the DI
121 121
                     $parameterInstances[] = $di->get($parameter->getClass()->getName());
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
      */
137 137
     public function getRegisteredObject()
138 138
     {
139
-        if($this->callableObject == null)
139
+        if ($this->callableObject == null)
140 140
         {
141 141
             $this->makeCallable();
142 142
         }
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
         // The class name without the namespace.
165 165
         $name = $this->reflectionClass->getShortName();
166 166
         // Append the classpath to the name
167
-        if(($this->classpath))
167
+        if (($this->classpath))
168 168
         {
169 169
             $name = $this->classpath . '\\' . $name;
170 170
         }
@@ -211,16 +211,16 @@  discard block
 block discarded – undo
211 211
     public function getMethods()
212 212
     {
213 213
         $aReturn = [];
214
-        foreach($this->reflectionClass->getMethods(\ReflectionMethod::IS_PUBLIC) as $xMethod)
214
+        foreach ($this->reflectionClass->getMethods(\ReflectionMethod::IS_PUBLIC) as $xMethod)
215 215
         {
216 216
             $sMethodName = $xMethod->getShortName();
217 217
             // Don't take magic __call, __construct, __destruct methods
218
-            if(strlen($sMethodName) > 2 && substr($sMethodName, 0, 2) == '__')
218
+            if (strlen($sMethodName) > 2 && substr($sMethodName, 0, 2) == '__')
219 219
             {
220 220
                 continue;
221 221
             }
222 222
             // Don't take excluded methods
223
-            if(in_array($sMethodName, $this->aProtectedMethods))
223
+            if (in_array($sMethodName, $this->aProtectedMethods))
224 224
             {
225 225
                 continue;
226 226
             }
@@ -241,37 +241,37 @@  discard block
 block discarded – undo
241 241
     public function configure($sMethod, $sName, $sValue)
242 242
     {
243 243
         // Set the namespace
244
-        if($sName == 'namespace')
244
+        if ($sName == 'namespace')
245 245
         {
246
-            if($sValue != '')
246
+            if ($sValue != '')
247 247
                 $this->namespace = $sValue;
248 248
             return;
249 249
         }
250 250
         // Set the classpath
251
-        if($sName == 'classpath')
251
+        if ($sName == 'classpath')
252 252
         {
253
-            if($sValue != '')
253
+            if ($sValue != '')
254 254
                 $this->classpath = trim($sValue, '\\');
255 255
             return;
256 256
         }
257 257
         // Set the separator
258
-        if($sName == 'separator')
258
+        if ($sName == 'separator')
259 259
         {
260
-            if($sValue == '_' || $sValue == '.')
260
+            if ($sValue == '_' || $sValue == '.')
261 261
                 $this->separator = $sValue;
262 262
             return;
263 263
         }
264 264
         // Set the excluded methods
265
-        if($sName == 'protected')
265
+        if ($sName == 'protected')
266 266
         {
267
-            if(is_array($sValue))
267
+            if (is_array($sValue))
268 268
                 $this->aProtectedMethods = array_merge($this->aProtectedMethods, $sValue);
269
-            elseif(is_string($sValue))
269
+            elseif (is_string($sValue))
270 270
                 $this->aProtectedMethods[] = $sValue;
271 271
             return;
272 272
         }
273 273
 
274
-        if(!isset($this->aConfiguration[$sMethod]))
274
+        if (!isset($this->aConfiguration[$sMethod]))
275 275
         {
276 276
             $this->aConfiguration[$sMethod] = [];
277 277
         }
@@ -292,16 +292,16 @@  discard block
 block discarded – undo
292 292
 
293 293
         // Common options to be set on all methods
294 294
         $aCommonConfig = array_key_exists('*', $this->aConfiguration) ? $this->aConfiguration['*'] : [];
295
-        foreach($this->reflectionClass->getMethods(\ReflectionMethod::IS_PUBLIC) as $xMethod)
295
+        foreach ($this->reflectionClass->getMethods(\ReflectionMethod::IS_PUBLIC) as $xMethod)
296 296
         {
297 297
             $sMethodName = $xMethod->getShortName();
298 298
             // Don't export magic __call, __construct, __destruct methods
299
-            if(strlen($sMethodName) > 0 && substr($sMethodName, 0, 2) == '__')
299
+            if (strlen($sMethodName) > 0 && substr($sMethodName, 0, 2) == '__')
300 300
             {
301 301
                 continue;
302 302
             }
303 303
             // Don't export "protected" methods
304
-            if(in_array($sMethodName, $this->aProtectedMethods))
304
+            if (in_array($sMethodName, $this->aProtectedMethods))
305 305
             {
306 306
                 continue;
307 307
             }
@@ -351,14 +351,14 @@  discard block
 block discarded – undo
351 351
      */
352 352
     public function call($sMethod, $aArgs)
353 353
     {
354
-        if(!$this->hasMethod($sMethod))
354
+        if (!$this->hasMethod($sMethod))
355 355
         {
356 356
             return;
357 357
         }
358 358
         $reflectionMethod = $this->reflectionClass->getMethod($sMethod);
359 359
         $callableObject = $this->getRegisteredObject();
360 360
         $response = $reflectionMethod->invokeArgs($callableObject, $aArgs);
361
-        if(($response))
361
+        if (($response))
362 362
         {
363 363
             $this->getResponseManager()->append($response);
364 364
         }
Please login to merge, or discard this patch.
Braces   +15 added lines, -12 removed lines patch added patch discarded remove patch
@@ -121,8 +121,7 @@  discard block
 block discarded – undo
121 121
                     $parameterInstances[] = $di->get($parameter->getClass()->getName());
122 122
                 }
123 123
                 $this->callableObject = $this->reflectionClass->newInstanceArgs($parameterInstances);
124
-            }
125
-            else
124
+            } else
126 125
             {
127 126
                 $this->callableObject = $this->reflectionClass->newInstance();
128 127
             }
@@ -243,31 +242,35 @@  discard block
 block discarded – undo
243 242
         // Set the namespace
244 243
         if($sName == 'namespace')
245 244
         {
246
-            if($sValue != '')
247
-                $this->namespace = $sValue;
245
+            if($sValue != '') {
246
+                            $this->namespace = $sValue;
247
+            }
248 248
             return;
249 249
         }
250 250
         // Set the classpath
251 251
         if($sName == 'classpath')
252 252
         {
253
-            if($sValue != '')
254
-                $this->classpath = trim($sValue, '\\');
253
+            if($sValue != '') {
254
+                            $this->classpath = trim($sValue, '\\');
255
+            }
255 256
             return;
256 257
         }
257 258
         // Set the separator
258 259
         if($sName == 'separator')
259 260
         {
260
-            if($sValue == '_' || $sValue == '.')
261
-                $this->separator = $sValue;
261
+            if($sValue == '_' || $sValue == '.') {
262
+                            $this->separator = $sValue;
263
+            }
262 264
             return;
263 265
         }
264 266
         // Set the excluded methods
265 267
         if($sName == 'protected')
266 268
         {
267
-            if(is_array($sValue))
268
-                $this->aProtectedMethods = array_merge($this->aProtectedMethods, $sValue);
269
-            elseif(is_string($sValue))
270
-                $this->aProtectedMethods[] = $sValue;
269
+            if(is_array($sValue)) {
270
+                            $this->aProtectedMethods = array_merge($this->aProtectedMethods, $sValue);
271
+            } elseif(is_string($sValue)) {
272
+                            $this->aProtectedMethods[] = $sValue;
273
+            }
271 274
             return;
272 275
         }
273 276
 
Please login to merge, or discard this patch.
src/Factory/Request.php 3 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
     public function setClassName($sClass)
41 41
     {
42 42
         $sClass = trim($sClass, '.\\ ');
43
-        if(($sClass))
43
+        if (($sClass))
44 44
         {
45 45
             $xCallable = jaxon()->di()->get($sClass);
46 46
             $this->sPrefix = $this->getOption('core.prefix.class') . $xCallable->getJsName() . '.';
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
         array_shift($aArguments);
84 84
 
85 85
         // Makes legacy code works
86
-        if(strpos($sFunction, '.') !== false)
86
+        if (strpos($sFunction, '.') !== false)
87 87
         {
88 88
             // If there is a dot in the name, then it is a call to a class
89 89
             $this->sPrefix = $this->getOption('core.prefix.class');
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -44,8 +44,7 @@
 block discarded – undo
44 44
         {
45 45
             $xCallable = jaxon()->di()->get($sClass);
46 46
             $this->sPrefix = $this->getOption('core.prefix.class') . $xCallable->getJsName() . '.';
47
-        }
48
-        else
47
+        } else
49 48
         {
50 49
             $this->sPrefix = $this->getOption('core.prefix.function');
51 50
         }
Please login to merge, or discard this patch.
Doc Comments   +2 added lines, -5 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
      *
36 36
      * @param string|null            $sClass              The callable class
37 37
      *
38
-     * @return Factory
38
+     * @return Request
39 39
      */
40 40
     public function setClassName($sClass)
41 41
     {
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
      *
59 59
      * @param CallableObject          $xCallable              The callable object
60 60
      *
61
-     * @return Factory
61
+     * @return Request
62 62
      */
63 63
     public function setCallable(CallableObject $xCallable)
64 64
     {
@@ -71,7 +71,6 @@  discard block
 block discarded – undo
71 71
      * Return the javascript call to a Jaxon function or object method
72 72
      *
73 73
      * @param string            $sFunction          The function or method (without class) name
74
-     * @param ...               $xParams            The parameters of the function or method
75 74
      *
76 75
      * @return \Jaxon\Request\Request
77 76
      */
@@ -100,7 +99,6 @@  discard block
 block discarded – undo
100 99
      * Return the javascript call to a generic function
101 100
      *
102 101
      * @param string            $sFunction          The function or method (with class) name
103
-     * @param ...               $xParams            The parameters of the function or method
104 102
      *
105 103
      * @return \Jaxon\Request\Request
106 104
      */
@@ -124,7 +122,6 @@  discard block
 block discarded – undo
124 122
      * @param integer       $nItemsPerPage          The number of items per page page
125 123
      * @param integer       $nCurrentPage           The current page
126 124
      * @param string        $sMethod                The name of function or a method prepended with its class name
127
-     * @param ...           $xParams                The parameters of the function or method
128 125
      *
129 126
      * @return string the pagination links
130 127
      */
Please login to merge, or discard this patch.