Test Failed
Push — master ( fc5a43...510786 )
by Fran
04:03
created

functions.php ➔ getallheaders()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
cc 3
eloc 6
nc 3
nop 0
dl 0
loc 8
ccs 0
cts 0
cp 0
crap 12
rs 9.4285
c 0
b 0
f 0
1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 5 and the first side effect is on line 43.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
use Symfony\Component\Finder\Finder;
3
//Cargamos en memoria la función de desarrollo PRE
4
if (!function_exists('pre')) {
5
    function pre($var, $die = FALSE)
6
    {
7
        $html = '<pre style="padding:10px;margin:0;display:block;background: #EEE; box-shadow: inset 0 0 3px 3px #DDD; color: #666; text-shadow: 1px 1px 1px #CCC;border-radius: 5px;">';
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 185 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
8
        $html .= (is_null($var)) ? '<b>NULL</b>' : print_r($var, TRUE);
9
        $html .= '</pre>';
10
        ob_start();
11
        echo $html;
12
        ob_flush();
13
        ob_end_clean();
14
        if ($die) {
15
            die;
0 ignored issues
show
Coding Style Compatibility introduced by
The function pre() contains an exit expression.

An exit expression should only be used in rare cases. For example, if you write a short command line script.

In most cases however, using an exit expression makes the code untestable and often causes incompatibilities with other libraries. Thus, unless you are absolutely sure it is required here, we recommend to refactor your code to avoid its usage.

Loading history...
16
        }
17
    }
18
}
19
20
if (!function_exists('jpre')) {
21
    function jpre($var, $die = false)
22
    {
23
        echo json_encode($var, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
24
        if ($die) {
25
            die;
0 ignored issues
show
Coding Style Compatibility introduced by
The function jpre() contains an exit expression.

An exit expression should only be used in rare cases. For example, if you write a short command line script.

In most cases however, using an exit expression makes the code untestable and often causes incompatibilities with other libraries. Thus, unless you are absolutely sure it is required here, we recommend to refactor your code to avoid its usage.

Loading history...
26
        }
27
    }
28
}
29
30
if (!function_exists("getallheaders")) {
31
    function getallheaders()
32
    {
33
        $headers = array();
34
        foreach ($_SERVER as $h => $v)
35
            if (preg_match('/HTTP_(.+)/', $h, $hp))
36
                $headers[$hp[1]] = $v;
37
        return $headers;
38
    }
39
}
40
41
if (file_exists(CORE_DIR)) {
42
    //Autoload de módulos
43
    $finder = new Finder();
44
    $finder->files()->in(CORE_DIR)->name('autoload.php');
45
    /* @var $file SplFileInfo */
46
    foreach ($finder as $file) {
47
        $path = $file->getRealPath();
48
        include_once($path);
49
    }
50
}