File: SqlDumper.php Lines 7 to 33
7 */
8class SqlDumper
9{
10    /**
11     * 実行するPrepared Statementを non-prepared なSQLにして返す
12     * @param string $psql (non) prepared statement sql
13     * @param array $params placeholders
14     * @return string binded sql
15     */
Type Class Description
checkstyle StaticBeforeVisibility The static declaration must come after the visibility declaration
pmd CyclomaticComplexity The method dump() has a Cyclomatic Complexity of 11. The configured cyclomatic complexity threshold is 10.
16
Type Class Description
checkstyle StaticBeforeVisibility The static declaration must come after the visibility declaration
pmd CyclomaticComplexity The method dump() has a Cyclomatic Complexity of 11. The configured cyclomatic complexity threshold is 10.
    static public function dump($psql, $params)
17    {
18        $keys = [];
19        $values = [];
20
21        $isNamedPlaceholders = false;
22        if (is_array($params) && !empty($params) && is_string(key($params))) {
Type Class Description
pmd ShortVariable Avoid variables with short names like $k1. Configured minimum length is 3.
pmd ShortVariable Avoid variables with short names like $k2. Configured minimum length is 3.
23
Type Class Description
pmd ShortVariable Avoid variables with short names like $k1. Configured minimum length is 3.
pmd ShortVariable Avoid variables with short names like $k2. Configured minimum length is 3.
            uksort($params, function ($k1, $k2) {
24                return strlen($k2) - strlen($k1);
25            });
26            $isNamedPlaceholders = true;
27        }
28
29        foreach ($params as $key => $value) {
30            if (is_string($key)) {
31                $keys[] = '/:' . ltrim($key, ':') . '/';
32            } else {
33                $keys[] = '/[?]/';
 
File: SqlDumper.php Lines 40 to 52
40            } elseif (is_float($value)) {
41                $values[] = strval($value);
42            } elseif (is_null($value)) {
43                $values[] = 'null';
44            }
45        }
46        if ($isNamedPlaceholders) {
47            return preg_replace($keys, $values, $psql);
48        } else {
Type Class Description
pmd UnusedLocalVariable Avoid unused local variables such as '$count'.
49
Type Class Description
pmd UnusedLocalVariable Avoid unused local variables such as '$count'.
            return preg_replace($keys, $values, $psql, 1, $count);
50        }
51    }
52}