Completed
Push — master ( 2f8a32...98ca7e )
by Lukas
03:37
created
src/GreyLogException/GreyLogException.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -163,8 +163,8 @@  discard block
 block discarded – undo
163 163
             parent::__construct($this->sExceptionMessage, $this->iExceptionCode);
164 164
             //set additional exception details
165 165
             $this->sExceptionShortMessage = $this->getExceptionCode($_aExceptionDetails, get_called_class());
166
-            $this->sExceptionClass = $this->getTrace()[0]['class'];
167
-            $this->sExceptionFunction = $this->getTrace()[0]['function'];
166
+            $this->sExceptionClass = $this->getTrace()[ 0 ][ 'class' ];
167
+            $this->sExceptionFunction = $this->getTrace()[ 0 ][ 'function' ];
168 168
             $this->sModuleName = get_called_class();
169 169
             //log exception
170 170
             $sFunctionToCall = $this->sExceptionLevel;
@@ -182,12 +182,12 @@  discard block
 block discarded – undo
182 182
      * @param array $_aExceptionDetails The exceptionDetails in form: "[int ExceptionCode, lfException::LOGLEVEL, string ExceptionMessage]".
183 183
      */
184 184
     private function validateExceptionDetails(Array $_aExceptionDetails) {
185
-        if (isset($_aExceptionDetails[0]) && is_numeric($_aExceptionDetails[0])) {
186
-            $this->iExceptionCode = $_aExceptionDetails[0];
187
-            if (isset($_aExceptionDetails[1]) && method_exists($this, $_aExceptionDetails[1])) {
188
-                $this->sExceptionLevel = $_aExceptionDetails[1];
189
-                if (isset($_aExceptionDetails[2]) && is_string($_aExceptionDetails[2])) {
190
-                    $this->sExceptionMessage = $_aExceptionDetails[2];
185
+        if (isset($_aExceptionDetails[ 0 ]) && is_numeric($_aExceptionDetails[ 0 ])) {
186
+            $this->iExceptionCode = $_aExceptionDetails[ 0 ];
187
+            if (isset($_aExceptionDetails[ 1 ]) && method_exists($this, $_aExceptionDetails[ 1 ])) {
188
+                $this->sExceptionLevel = $_aExceptionDetails[ 1 ];
189
+                if (isset($_aExceptionDetails[ 2 ]) && is_string($_aExceptionDetails[ 2 ])) {
190
+                    $this->sExceptionMessage = $_aExceptionDetails[ 2 ];
191 191
                 } else {
192 192
                     $this->sExceptionMessage = "__ERR_NOT_FOUND__";
193 193
                     $this->innerNotice("WrongConfig", "The exeption thrown, has no exceptionMessage.");
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
      */
225 225
     public function getNumberOfVariables(string $_sReplaceableString) {
226 226
         if (preg_match_all("~%(?:(\d+)[$])?[-+]?(?:[ 0]|['].)?(?:[-]?\d+)?(?:[.]\d+)?[%bcdeEufFgGosxX]~", $_sReplaceableString, $iNumberOfVariables) > 0) {
227
-            return count($iNumberOfVariables[1]);
227
+            return count($iNumberOfVariables[ 1 ]);
228 228
         }
229 229
         return 0;
230 230
     }
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
     public function getExceptionCode($_aExceptionDetails, $_sExceptionClass) {
241 241
         $oClass = new \ReflectionClass($_sExceptionClass);
242 242
         $sExceptionCode = array_search($_aExceptionDetails, $oClass->getConstants());
243
-        if($sExceptionCode === false){
243
+        if ($sExceptionCode === false) {
244 244
             $sExceptionCode = "UNKNOWN";
245 245
         }
246 246
         return $sExceptionCode;
@@ -441,7 +441,7 @@  discard block
 block discarded – undo
441 441
         //get function/method parameters and parameters function was called
442 442
         $ref = new \ReflectionMethod($this->sExceptionClass, $this->sExceptionFunction);
443 443
         $aFunctionParameters = $ref->getParameters();
444
-        $aFunctionParametersSetted = $this->getTrace()[0]['args'];
444
+        $aFunctionParametersSetted = $this->getTrace()[ 0 ][ 'args' ];
445 445
         //log notice if number of parameters does not match
446 446
         if (count($aFunctionParameters) < count($aFunctionParametersSetted)) {
447 447
             $this->innerNotice("MissUse", "Function was called with '" . count($aFunctionParametersSetted) . "' parameters, but defined on function is only '" . count($aFunctionParameters) . "'");
@@ -449,10 +449,10 @@  discard block
 block discarded – undo
449 449
         //add parameters and values to exception to log
450 450
         $i = 0;
451 451
         foreach ($aFunctionParametersSetted as $mParameterValue) {
452
-            if (!isset($aFunctionParameters[$i])) {
452
+            if (!isset($aFunctionParameters[ $i ])) {
453 453
                 $this->gelfMessage->setAdditional("Param_UNKNOWN" . $i, serialize($mParameterValue));
454 454
             } else {
455
-                $this->gelfMessage->setAdditional("Param_" . $aFunctionParameters[$i]->name, serialize($mParameterValue));
455
+                $this->gelfMessage->setAdditional("Param_" . $aFunctionParameters[ $i ]->name, serialize($mParameterValue));
456 456
             }
457 457
             $i++;
458 458
         }
Please login to merge, or discard this patch.