Failed Conditions
Pull Request — master (#106)
by
unknown
02:31
created

UUIDStringToNum::getValue()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 3
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace ClickHouseDB\Query\Expression;
6
7
/**
8
 * Pass expression "as is" to be sent and executed at server.
9
 * P.ex.: `new Expression\Function\UUIDStringToNum('0f372656-6a5b-4727-a4c4-f6357775d926');`
10
 */
11
class UUIDStringToNum implements Expression
12
{
13
    /** @var string */
14
    private $uuid;
15
16
    public function __construct(string $uuid)
17
    {
18
        $this->$uuid = $uuid;
19
    }
20
21
    public function needsEncoding(): bool
0 ignored issues
show
introduced by
There must be exactly 1 whitespace between closing parenthesis and return type colon.
Loading history...
22
    {
23
        return false;
24
    }
25
26
    public function getValue(): string
0 ignored issues
show
introduced by
There must be exactly 1 whitespace between closing parenthesis and return type colon.
Loading history...
27
    {
28
        return "UUIDStringToNum('{$this->uuid}')";
0 ignored issues
show
Coding Style Best Practice introduced by
Variable "%s" not allowed in double quoted string; use sprintf() or concatenation instead

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
29
    }
30
}
31