Passed
Push — master ( 8ccdb4...872254 )
by Fran
04:34
created

pre()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 11
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 9
c 1
b 0
f 0
nc 4
nop 2
dl 0
loc 11
rs 9.9666
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
    function pre($var, $die = FALSE)
9
    {
10
        $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;">';
11
        $html .= is_null($var) ? '<b>NULL</b>' : print_r($var, TRUE);
12
        $html .= '</pre>';
13
        ob_start();
14
        echo $html;
15
        ob_flush();
16
        ob_end_clean();
17
        if ($die) {
18
            die;
19
        }
20
    }
21
}
22
23
if (!function_exists('jpre')) {
24
    function jpre($var, $die = false)
25
    {
26
        echo json_encode($var, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
27
        if ($die) {
28
            die;
29
        }
30
    }
31
}
32
33
if (!function_exists("getallheaders")) {
34
    function getallheaders()
35
    {
36
        $headers = [];
37
        foreach ($_SERVER as $h => $v)
38
            if (preg_match('/HTTP_(.+)/', $h, $hp)) {
39
                $headers[$hp[1]] = $v;
40
            }
41
        return $headers;
42
    }
43
}
44
45
if (file_exists(CORE_DIR)) {
46
    $loaded_files = [];
47
    //Autoload de módulos
48
    $finder = new Finder();
49
    $finder->files()->in(CORE_DIR)->name('autoload.php');
50
    /* @var $file SplFileInfo */
51
    foreach ($finder as $file) {
52
        $path = $file->getRealPath();
53
        if(!in_array($path, $loaded_files)) {
54
            $loaded_files[] = $path;
55
            require_once($path);
56
        }
57
    }
58
}
59
60
if(!function_exists('t')) {
61
    function t($message, $key = null, $reload = false) {
62
        return CustomTranslateExtension::_($message, $key, $reload);
63
    }
64
}