Completed
Push — master ( a42924...6fb51e )
by Thierry
01:41
created
src/Request/Support/UserFunction.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
      */
85 85
     public function configure($sName, $sValue)
86 86
     {
87
-        switch($sName)
87
+        switch ($sName)
88 88
         {
89 89
         case 'class': // The user function is a method in the given class
90 90
             $this->xUserFunction = [$sValue, $this->xUserFunction];
@@ -139,13 +139,13 @@  discard block
 block discarded – undo
139 139
      */
140 140
     public function call($aArgs = [])
141 141
     {
142
-        if(($this->sInclude))
142
+        if (($this->sInclude))
143 143
         {
144 144
             require_once $this->sInclude;
145 145
         }
146 146
 
147 147
         // If the function is an alias for a class method, then instanciate the class
148
-        if(is_array($this->xUserFunction) && is_string($this->xUserFunction[0]))
148
+        if (is_array($this->xUserFunction) && is_string($this->xUserFunction[0]))
149 149
         {
150 150
             $sClassName = $this->xUserFunction[0];
151 151
             $this->xUserFunction[0] = new $sClassName;
Please login to merge, or discard this patch.
src/Request/Plugin/UserFunction.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -47,11 +47,11 @@  discard block
 block discarded – undo
47 47
 
48 48
     public function __construct()
49 49
     {
50
-        if(isset($_GET['jxnfun']))
50
+        if (isset($_GET['jxnfun']))
51 51
         {
52 52
             $this->sRequestedFunction = $_GET['jxnfun'];
53 53
         }
54
-        if(isset($_POST['jxnfun']))
54
+        if (isset($_POST['jxnfun']))
55 55
         {
56 56
             $this->sRequestedFunction = $_POST['jxnfun'];
57 57
         }
@@ -78,30 +78,30 @@  discard block
 block discarded – undo
78 78
      */
79 79
     public function register($sType, $sUserFunction, $aOptions)
80 80
     {
81
-        if($sType != $this->getName())
81
+        if ($sType != $this->getName())
82 82
         {
83 83
             return false;
84 84
         }
85 85
 
86
-        if(!is_string($sUserFunction))
86
+        if (!is_string($sUserFunction))
87 87
         {
88 88
             throw new \Jaxon\Exception\Error($this->trans('errors.functions.invalid-declaration'));
89 89
         }
90 90
 
91
-        if(is_string($aOptions))
91
+        if (is_string($aOptions))
92 92
         {
93 93
             $aOptions = ['include' => $aOptions];
94 94
         }
95
-        if(!is_array($aOptions))
95
+        if (!is_array($aOptions))
96 96
         {
97 97
             throw new \Jaxon\Exception\Error($this->trans('errors.functions.invalid-declaration'));
98 98
         }
99 99
 
100 100
         // Check if an alias is defined
101 101
         $sFunctionName = $sUserFunction;
102
-        foreach($aOptions as $sName => $sValue)
102
+        foreach ($aOptions as $sName => $sValue)
103 103
         {
104
-            if($sName == 'alias')
104
+            if ($sName == 'alias')
105 105
             {
106 106
                 $sFunctionName = $sValue;
107 107
                 break;
@@ -109,11 +109,11 @@  discard block
 block discarded – undo
109 109
         }
110 110
 
111 111
         $this->aFunctions[$sFunctionName] = $aOptions;
112
-        jaxon()->di()->set($sFunctionName, function () use ($sFunctionName, $sUserFunction) {
112
+        jaxon()->di()->set($sFunctionName, function() use ($sFunctionName, $sUserFunction) {
113 113
             $xUserFunction = new \Jaxon\Request\Support\UserFunction($sUserFunction);
114 114
 
115 115
             $aOptions = $this->aFunctions[$sFunctionName];
116
-            foreach($aOptions as $sName => $sValue)
116
+            foreach ($aOptions as $sName => $sValue)
117 117
             {
118 118
                 $xUserFunction->configure($sName, $sValue);
119 119
             }
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
     {
144 144
         $di = jaxon()->di();
145 145
         $code = '';
146
-        foreach(array_keys($this->aFunctions) as $sName)
146
+        foreach (array_keys($this->aFunctions) as $sName)
147 147
         {
148 148
             $xFunction = $di->get($sName);
149 149
             $code .= $xFunction->getScript();
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
     public function canProcessRequest()
160 160
     {
161 161
         // Check the validity of the function name
162
-        if(($this->sRequestedFunction) && !$this->validateFunction($this->sRequestedFunction))
162
+        if (($this->sRequestedFunction) && !$this->validateFunction($this->sRequestedFunction))
163 163
         {
164 164
             $this->sRequestedFunction = null;
165 165
         }
@@ -173,12 +173,12 @@  discard block
 block discarded – undo
173 173
      */
174 174
     public function processRequest()
175 175
     {
176
-        if(!$this->canProcessRequest())
176
+        if (!$this->canProcessRequest())
177 177
         {
178 178
             return false;
179 179
         }
180 180
 
181
-        if(!key_exists($this->sRequestedFunction, $this->aFunctions))
181
+        if (!key_exists($this->sRequestedFunction, $this->aFunctions))
182 182
         {
183 183
             // Unable to find the requested function
184 184
             throw new \Jaxon\Exception\Error($this->trans('errors.functions.invalid',
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
         $xFunction = jaxon()->di()->get($this->sRequestedFunction);
189 189
         $aArgs = $this->getRequestManager()->process();
190 190
         $xResponse = $xFunction->call($aArgs);
191
-        if(($xResponse))
191
+        if (($xResponse))
192 192
         {
193 193
             $this->getResponseManager()->append($xResponse);
194 194
         }
Please login to merge, or discard this patch.