QueryString::readableSqlQuery()   A
last analyzed

Complexity

Conditions 3
Paths 1

Size

Total Lines 13
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 9
nc 1
nop 1
dl 0
loc 13
ccs 0
cts 10
cp 0
crap 12
rs 9.9666
c 1
b 0
f 0
1
<?php
2
3
namespace NovaExportConfiguration\Helpers;
4
5
class QueryString
6
{
7
    public static function readableSqlQuery($query): string
8
    {
9
        return \Illuminate\Support\Str::replaceArray(
10
            '?',
11
            collect($query->getBindings())
12
                ->map(function ($i) {
13
                    if (is_object($i)) {
14
                        $i = (string) $i;
15
                    }
16
17
                    return (is_string($i)) ? "'$i'" : $i;
18
                })->all(),
19
            $query->toSql()
20
        );
21
    }
22
}
23