mysqli_strict::bind_param()   B
last analyzed

Complexity

Conditions 11
Paths 11

Size

Total Lines 32

Duplication

Lines 8
Ratio 25 %

Code Coverage

Tests 0
CRAP Score 132

Importance

Changes 0
Metric Value
dl 8
loc 32
ccs 0
cts 32
cp 0
rs 7.3166
c 0
b 0
f 0
cc 11
nc 11
nop 1
crap 132

How to fix   Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php 
2
$defflip = (!cfip()) ? exit(header('HTTP/1.1 401 Unauthorized')) : 1;
3
4
class mysqli_strict extends mysqli {
5
  public function bind_param($paramTypes) {
6
    if (!is_string($paramTypes)) {
7
      return false;
8
    } else {
9
      $args = func_get_args();
10
      $acopy = $args;
11
      $nargs = count($args);
12
      for($i=1;$i<$nargs;$i++) {
13
        $ipos = ($i-1);
14
        $pos = substr($paramTypes, $ipos, 1);
15
        switch ($pos) {
16
        	case 's':
17
        	  $return_str = filter_var($acopy[$i], FILTER_VALIDATE_STRING, FILTER_NULL_ON_FAILURE);
18
        	  $acopy[$i] = ($return_str !== null) ? (string)$return_str : null;
19
        	  break;
20 View Code Duplication
        	case 'i':
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
21
        	  $return_int = filter_var($acopy[$i], FILTER_VALIDATE_INT, FILTER_NULL_ON_FAILURE);
22
        	  $acopy[$i] = ($return_int !== null) ? (int)$return_int : null;
23
        	  break;
24
        	case 'd':
25
        	  $return_dbl = filter_var($acopy[$i], FILTER_VALIDATE_FLOAT, FILTER_NULL_ON_FAILURE);
26
        	  $acopy[$i] = ($return_dbl !== null) ? (float)$return_dbl : null;
27
        	  break;
28 View Code Duplication
        	case 'b':
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
29
        	  $return_bool = filter_var($acopy[$i], FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE);
30
        	  $acopy[$i] = ($return_bool !== null) ? (bool)$return_bool : null;
31
        	  break;
32
        }
33
      }
34
      return (in_array(null, $acopy));
35
    }
36
  }
37
}
38