From::__construct()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 9
c 0
b 0
f 0
ccs 5
cts 5
cp 1
rs 9.6666
cc 2
eloc 4
nc 2
nop 2
crap 2
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace Puzzle\QueryBuilder\Queries\Snippets;
6
7
use Puzzle\QueryBuilder\Snippet;
8
9
class From implements Snippet
10
{
11
    private
12
        $tableName;
1 ignored issue
show
Coding Style introduced by
The visibility should be declared for property $tableName.

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
14
    /**
15
     * @param TableName|string $table
16
     */
17 36
    public function __construct($table, ?string $alias = null)
18
    {
19 36
        if(! $table instanceof TableName)
20
        {
21 34
            $table = new TableName($table, $alias);
22
        }
23
24 34
        $this->tableName = $table;
25 34
    }
26
27 32
    public function toString(): string
28
    {
29 32
        return sprintf('FROM %s', $this->tableName->toString());
30
    }
31
}
32