Completed
Push — master ( e4d7f8...3dffac )
by Thierry
02:42
created
src/Request/Plugin/CallableObject.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -67,19 +67,19 @@  discard block
 block discarded – undo
67 67
         $this->sRequestedClass = null;
68 68
         $this->sRequestedMethod = null;
69 69
 
70
-        if(!empty($_GET['jxncls']))
70
+        if (!empty($_GET['jxncls']))
71 71
         {
72 72
             $this->sRequestedClass = $_GET['jxncls'];
73 73
         }
74
-        if(!empty($_GET['jxnmthd']))
74
+        if (!empty($_GET['jxnmthd']))
75 75
         {
76 76
             $this->sRequestedMethod = $_GET['jxnmthd'];
77 77
         }
78
-        if(!empty($_POST['jxncls']))
78
+        if (!empty($_POST['jxncls']))
79 79
         {
80 80
             $this->sRequestedClass = $_POST['jxncls'];
81 81
         }
82
-        if(!empty($_POST['jxnmthd']))
82
+        if (!empty($_POST['jxnmthd']))
83 83
         {
84 84
             $this->sRequestedMethod = $_POST['jxnmthd'];
85 85
         }
@@ -104,33 +104,33 @@  discard block
 block discarded – undo
104 104
      */
105 105
     public function register($aArgs)
106 106
     {
107
-        if(count($aArgs) > 1)
107
+        if (count($aArgs) > 1)
108 108
         {
109 109
             $sType = $aArgs[0];
110 110
 
111
-            if($sType == Jaxon::CALLABLE_OBJECT)
111
+            if ($sType == Jaxon::CALLABLE_OBJECT)
112 112
             {
113 113
                 $xCallableObject = $aArgs[1];
114 114
 
115
-                if(!is_object($xCallableObject) && !is_string($xCallableObject))
115
+                if (!is_object($xCallableObject) && !is_string($xCallableObject))
116 116
                 {
117 117
                     throw new \Jaxon\Exception\Error($this->trans('errors.objects.instance'));
118 118
                 }
119
-                if(is_string($xCallableObject) && !class_exists($xCallableObject))
119
+                if (is_string($xCallableObject) && !class_exists($xCallableObject))
120 120
                 {
121 121
                     throw new \Jaxon\Exception\Error($this->trans('errors.objects.instance'));
122 122
                 }
123
-                if(!($xCallableObject instanceof \Jaxon\Request\Support\CallableObject))
123
+                if (!($xCallableObject instanceof \Jaxon\Request\Support\CallableObject))
124 124
                 {
125 125
                     $xCallableObject = new \Jaxon\Request\Support\CallableObject($xCallableObject);
126 126
                 }
127
-                if(count($aArgs) > 2 && is_array($aArgs[2]))
127
+                if (count($aArgs) > 2 && is_array($aArgs[2]))
128 128
                 {
129
-                    foreach($aArgs[2] as $sKey => $aValue)
129
+                    foreach ($aArgs[2] as $sKey => $aValue)
130 130
                     {
131
-                        foreach($aValue as $sName => $sValue)
131
+                        foreach ($aValue as $sName => $sValue)
132 132
                         {
133
-                            if($sName == 'classpath' && $sValue != '')
133
+                            if ($sName == 'classpath' && $sValue != '')
134 134
                                 $this->aClassPaths[] = $sValue;
135 135
                             $xCallableObject->configure($sKey, $sName, $sValue);
136 136
                         }
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
     public function generateHash()
154 154
     {
155 155
         $sHash = '';
156
-        foreach($this->aCallableObjects as $xCallableObject)
156
+        foreach ($this->aCallableObjects as $xCallableObject)
157 157
         {
158 158
             $sHash .= $xCallableObject->getName();
159 159
             $sHash .= implode('|', $xCallableObject->getMethods());
@@ -172,15 +172,15 @@  discard block
 block discarded – undo
172 172
         // Generate code for javascript classes declaration
173 173
         $code = '';
174 174
         $classes = array();
175
-        foreach($this->aClassPaths as $sClassPath)
175
+        foreach ($this->aClassPaths as $sClassPath)
176 176
         {
177 177
             $offset = 0;
178 178
             $sClassPath .= '.Null'; // This is a sentinel. The last token is not processed in the while loop.
179
-            while(($dotPosition = strpos($sClassPath, '.', $offset)) !== false)
179
+            while (($dotPosition = strpos($sClassPath, '.', $offset)) !== false)
180 180
             {
181 181
                 $class = substr($sClassPath, 0, $dotPosition);
182 182
                 // Generate code for this class
183
-                if(!array_key_exists($class, $classes))
183
+                if (!array_key_exists($class, $classes))
184 184
                 {
185 185
                     $code .= "$sJaxonPrefix$class = {};\n";
186 186
                     $classes[$class] = $class;
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
             }
190 190
         }
191 191
 
192
-        foreach($this->aCallableObjects as $xCallableObject)
192
+        foreach ($this->aCallableObjects as $xCallableObject)
193 193
         {
194 194
             $code .= $xCallableObject->getScript();
195 195
         }
@@ -204,13 +204,13 @@  discard block
 block discarded – undo
204 204
     public function canProcessRequest()
205 205
     {
206 206
         // Check the validity of the class name
207
-        if(($this->sRequestedClass) && !$this->validateClass($this->sRequestedClass))
207
+        if (($this->sRequestedClass) && !$this->validateClass($this->sRequestedClass))
208 208
         {
209 209
             $this->sRequestedClass = null;
210 210
             $this->sRequestedMethod = null;
211 211
         }
212 212
         // Check the validity of the method name
213
-        if(($this->sRequestedMethod) && !$this->validateMethod($this->sRequestedMethod))
213
+        if (($this->sRequestedMethod) && !$this->validateMethod($this->sRequestedMethod))
214 214
         {
215 215
             $this->sRequestedClass = null;
216 216
             $this->sRequestedMethod = null;
@@ -225,21 +225,21 @@  discard block
 block discarded – undo
225 225
      */
226 226
     public function processRequest()
227 227
     {
228
-        if(!$this->canProcessRequest())
228
+        if (!$this->canProcessRequest())
229 229
             return false;
230 230
 
231 231
         $aArgs = $this->getRequestManager()->process();
232 232
 
233 233
         // Try to register an instance of the requested class, if it isn't yet
234
-        if(!array_key_exists($this->sRequestedClass, $this->aCallableObjects))
234
+        if (!array_key_exists($this->sRequestedClass, $this->aCallableObjects))
235 235
         {
236 236
             $this->getPluginManager()->registerClass($this->sRequestedClass);
237 237
         }
238 238
 
239
-        if(array_key_exists($this->sRequestedClass, $this->aCallableObjects))
239
+        if (array_key_exists($this->sRequestedClass, $this->aCallableObjects))
240 240
         {
241 241
             $xCallableObject = $this->aCallableObjects[$this->sRequestedClass];
242
-            if($xCallableObject->hasMethod($this->sRequestedMethod))
242
+            if ($xCallableObject->hasMethod($this->sRequestedMethod))
243 243
             {
244 244
                 $xCallableObject->call($this->sRequestedMethod, $aArgs);
245 245
                 return true;
@@ -260,11 +260,11 @@  discard block
 block discarded – undo
260 260
     public function getRegisteredObject($sClassName = null)
261 261
     {
262 262
         $sClassName = (string)$sClassName;
263
-        if(!$sClassName)
263
+        if (!$sClassName)
264 264
         {
265 265
             $sClassName = $this->sRequestedClass;
266 266
         }
267
-        if(!array_key_exists($sClassName, $this->aCallableObjects))
267
+        if (!array_key_exists($sClassName, $this->aCallableObjects))
268 268
         {
269 269
             return null;
270 270
         }
Please login to merge, or discard this patch.