Passed
Push — main ( 436d8c...f01a67 )
by Peter
02:36
created

Table   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
dl 0
loc 36
rs 10
c 1
b 0
f 0
ccs 10
cts 10
cp 1
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __toString() 0 7 2
A __construct() 0 4 1
A getParams() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace QB\Generic\Clause;
6
7
use QB\Generic\IQueryPart;
8
9
class Table implements IQueryPart
10
{
11
    protected string $tableName;
12
13
    protected ?string $alias = null;
14
15
    /**
16
     * Expr constructor.
17
     *
18
     * @param string      $tableName table name
19
     * @param string|null $alias
20
     */
21 18
    public function __construct(string $tableName, ?string $alias = null)
22
    {
23 18
        $this->tableName = $tableName;
24 18
        $this->alias     = $alias;
25 18
    }
26
27
    /**
28
     * @return string
29
     */
30 17
    public function __toString(): string
31
    {
32 17
        if ($this->alias === null) {
33 4
            return $this->tableName;
34
        }
35
36 13
        return sprintf('%s AS %s', $this->tableName, $this->alias);
37
    }
38
39
    /**
40
     * @return array
41
     */
42 1
    public function getParams(): array
43
    {
44 1
        return [];
45
    }
46
}
47