GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Push — master ( 2caa1d...bfd858 )
by Hendrik
01:55
created

Functions::stripString()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 8
ccs 0
cts 0
cp 0
rs 9.4285
cc 1
eloc 5
nc 1
nop 1
crap 2
1
<?php
2
3
namespace FatFramework;
4
5
class Functions
6
{
7
    /**
8
     * String Transformer
9
     * Formats a 16-digit credit card number into 4-digit-blocks
10
     * 
11
     * @param string $cc 16-digit credit cardnum
12
     * 
13
     * @return string 4-digit-block formatted credit cardnum
14
     */
15 1
    public static function formatCreditCardNum($cc) {
16 1
        $sDivider = ' ';
17 1
        $cc_length = strlen($cc);
18 1
        $newCreditCard = substr($cc, -4);
19
20 1
        for ($i = $cc_length - 5; $i >= 0; $i--) {
21 1
            if ((($i + 1) - $cc_length)%4 == 0) {
22 1
                $newCreditCard = $sDivider . $newCreditCard;
23 1
            }
24 1
            $newCreditCard = $cc[$i] . $newCreditCard;
25 1
        }
26
27 1
        return $newCreditCard;
28
    }
29
    
30
    /**
31
     * String Transformer
32
     * Date string converter for dates loaded from database 
33
     * and shown in templates, mails etc.
34
     * 
35
     * @param string $sDate Date formatted like 2000-12-24
36
     * 
37
     * @return string $sGermanDate Date formatted like 24.12.2000
38
     */
39 1
    public static function formatMysqlDate($sDate)
40
    {
41 1
        $aD = explode("-", $sDate);
42 1
        $sGermanDate = sprintf("%02d.%02d.%04d", $aD[2], $aD[1], $aD[0]);
43 1
        return $sGermanDate;
44
    }
45
    
46
    /**
47
     * Get cleaned GET or POST parameters.
48
     * Avoid SQL-Injection etc.
49
     * 
50
     * @param string $sParam Parameter-name
0 ignored issues
show
Bug introduced by
There is no parameter named $sParam. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
51
     * 
52
     * @return string $sParamValue Parameter-value OR false
53
     */
54 1
    public static function getRequestParameter($param) {
0 ignored issues
show
Coding Style introduced by
getRequestParameter uses the super-global variable $_REQUEST which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
55
        $return = false;
56 1
        if (isset($_REQUEST[$param])) {
57
            $paramValue = $_REQUEST[$param];
58 1
        }
59 1
        if (isset($paramValue) && is_string($paramValue)) {
60 1
            $return = self::stripString($paramValue);
61
        } elseif (isset($paramValue) && is_array($paramValue)) {
62 1
            foreach ($paramValue AS $key => $value) {
63 1
                $return[$key] = self::stripString($value);
64 1
            }
65 1
        }
66
        return $return;
67 1
    }
68 1
69
    /**
70 1
     * Auto loads all php files in $directoryPath (not recursive)
71
     * auto include all files in given directory
72
     * 
73
     * @param string $directoryPath
74
     * 
75
     * @return void
76
     */
77
    public static function includeDir($directoryPath)
78
    {
79
        $aIncludeFiles = scandir($directoryPath);
80
        $i = 1;
81 1
        foreach ($aIncludeFiles AS $file) {
82
            if ($i >= 3 && !is_dir($directoryPath . $file) && substr($directoryPath . $file, -3, 3) == 'php') {
83 1
                include_once($directoryPath . $file);
84 1
            }
85 1
            $i++;
86 1
        }
87 1
    }
88 1
    
89 1
    /**
90 1
     * String Trasformer
91 1
     * Removes whitespace and empty lines from a html-source.
92
     * 
93
     * @param string $sHtml HTML sourcecode
94
     * 
95
     * @return string $sCleanedHtml Reduced HTML sourcecode
96
     */
97
    public static function reduceHtml($sHtml) {
98
        $sCleanedHtml = "";
99
        $aHtmlLines = explode("\n", $sHtml);
100
        foreach ($aHtmlLines as $sLine) {
101 1
            if (trim($sLine) != "") {
102 1
                $sCleanedHtml .= trim($sLine) . "\n";
103 1
            }
104 1
        }
105 1
        return $sCleanedHtml;
106 1
    }
107 1
    
108 1
    /**
109 1
     * Strip evil chars from a parameter-string to avoid hacking.
110
     *
111
     * @param string $sString
112
     *
113
     * @return string $sStrippedString
114
     */
115
    public static function stripString($sString) {
116
        $sStrippedString = str_replace(
117
            array('&', '<', '>', '"', "'", chr(0), '\\', "\n", "\r"), 
118
            array('&amp;', '&lt;', '&gt;', '&quot;', '&#039;', '', '&#092;', '&#10;', '&#13;'), $sString
119
        );
120
121
        return $sStrippedString;
122
    }
123
}
124