Passed
Push — master ( ab5b91...849dc0 )
by Fran
03:17
created

jpre()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 3
c 1
b 0
f 0
nc 2
nop 2
dl 0
loc 5
ccs 0
cts 3
cp 0
crap 6
rs 10
1
<?php
2
3
use PSFS\base\extension\CustomTranslateExtension;
4
use Symfony\Component\Finder\Finder;
5
6
//Cargamos en memoria la función de desarrollo PRE
7
if (!function_exists('pre')) {
8
    /**
9
     * @param mixed $var
10
     * @param boolean $die
11
     * @return void
12
     */
13
    function pre(mixed $var, bool $die = false): void
14
    {
15 1
        $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;">';
16 1
        $html .= is_null($var) ? '<b>NULL</b>' : print_r($var, TRUE);
17 1
        $html .= '</pre>';
18 1
        echo $html;
19 1
        if ($die) {
20
            die;
21
        }
22
    }
23
}
24
25
if (!function_exists("getallheaders")) {
26
    function getallheaders(): array
27
    {
28 2
        $headers = [];
29 2
        foreach ($_SERVER as $h => $v)
30 2
            if (preg_match('/HTTP_(.+)/', $h, $hp)) {
31
                $headers[$hp[1]] = $v;
32
            }
33 2
        return $headers;
34
    }
35
}
36
37
if (file_exists(CORE_DIR)) {
38
    $loaded_files = [];
39
    //Autoload de módulos
40
    $finder = new Finder();
41
    $finder->files()->in(CORE_DIR)->name('autoload.php');
42
    /* @var $file SplFileInfo */
43
    foreach ($finder as $file) {
44
        $path = $file->getRealPath();
45
        if (!in_array($path, $loaded_files)) {
46
            $loaded_files[] = $path;
47
            require_once($path);
48
        }
49
    }
50
}
51
52
if (!function_exists('t')) {
53
    function t($message, $key = null, $reload = false)
54
    {
55 10
        return CustomTranslateExtension::_($message, $key, $reload);
56
    }
57
}
58