Completed
Push — master ( e6533f...d6c42a )
by Woody
12s
created

functions.php ➔ isStatement()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
ccs 1
cts 1
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
declare(strict_types=1);
3
4
namespace Latitude\QueryBuilder;
5
6
function isQuery($value): bool
7
{
8 2
    return $value instanceof Query;
9
}
10
11
function isStatement($value): bool
12
{
13 14
    return $value instanceof Statement;
14
}
15
16
function reference($sql): Statement
17
{
18 14
    if (isStatement($sql)) {
19 2
        return $sql;
20
    }
21
22 12
    if (strpos($sql, ' ') === false) {
23 12
        return Reference::make($sql);
24
    }
25
26 2
    return Alias::make(...\preg_split('/ (?:AS )?/i', $sql));
0 ignored issues
show
Bug introduced by Woody Gilk
The call to make() misses a required argument $alias.

This check looks for function calls that miss required arguments.

Loading history...
Documentation introduced by Woody Gilk
\preg_split('/ (?:AS )?/i', $sql) is of type array, but the function expects a object<Latitude\QueryBuilder\Statement>|string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
27
}
28