IlluminateQueryDebugger   A
last analyzed

Complexity

Total Complexity 13

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 13
lcom 0
cbo 0
dl 0
loc 28
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
B onAfterEpilogHandler() 0 12 10
A interpolateQuery() 0 12 3
1
<?php
2
3
namespace Arrilot\BitrixModels\Debug;
4
5
use Illuminate\Database\Capsule\Manager;
6
7
class IlluminateQueryDebugger
8
{
9
    public static function onAfterEpilogHandler()
10
    {
11
        global $DB, $USER;
12
13
        $bExcel = isset($_REQUEST["mode"]) && $_REQUEST["mode"] === 'excel';
14
        if (!defined("ADMIN_AJAX_MODE") && !defined('PUBLIC_AJAX_MODE') && !$bExcel) {
15
            $bShowStat = ($DB->ShowSqlStat && ($USER->CanDoOperation('edit_php') || $_SESSION["SHOW_SQL_STAT"]=="Y"));
16
            if ($bShowStat && class_exists(Manager::class) && Manager::logging()) {
17
                require_once(__DIR__.'/debug_info.php');
18
            }
19
        }
20
    }
21
    
22
    public static function interpolateQuery($query, $params)
23
    {
24
        $keys = array();
25
26
        # build a regular expression for each parameter
27
        foreach ($params as $key => $value) {
28
            $keys[] = is_string($key) ? '/:'.$key.'/' : '/[?]/';
29
            $params[$key] = "'" . $value . "'";
30
        }
31
    
32
        return preg_replace($keys, $params, $query, 1, $count);
33
    }
34
}
35