On::toString()   A
last analyzed

Complexity

Conditions 3
Paths 2

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 3

Importance

Changes 0
Metric Value
dl 0
loc 13
c 0
b 0
f 0
ccs 7
cts 7
cp 1
rs 9.4285
cc 3
eloc 7
nc 2
nop 0
crap 3
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace Puzzle\QueryBuilder\Queries\Snippets;
6
7
use Puzzle\QueryBuilder\Snippet;
8
9
class On implements Snippet
10
{
11
    private
12
        $leftColumn,
1 ignored issue
show
Coding Style introduced by
It is generally advisable to only define one property per statement.

Only declaring a single property per statement allows you to later on add doc comments more easily.

It is also recommended by PSR2, so it is a common style that many people expect.

Loading history...
Coding Style introduced by
The visibility should be declared for property $leftColumn.

The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using

class A {
    var $property;
}

the property is implicitly global.

To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.

Loading history...
13
        $rightColumn;
14
15 24
    public function __construct(?string $leftColumn, ?string $rightColumn)
16
    {
17 24
        $this->leftColumn = (string) $leftColumn;
18 24
        $this->rightColumn = (string) $rightColumn;
19 24
    }
20
21 24
    public function toString(): string
22
    {
23 24
        if(empty($this->leftColumn) || empty($this->rightColumn))
24
        {
25 6
            return '';
26
        }
27
28 18
        return sprintf(
29 18
            'ON %s = %s',
30 18
            $this->leftColumn,
31 18
            $this->rightColumn
32
        );
33
    }
34
}
35