TableName   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%
Metric Value
dl 0
loc 28
wmc 4
lcom 1
cbo 0
ccs 12
cts 12
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 11 2
A toString() 0 9 2
1
<?php
2
3
namespace Muffin\Queries\Snippets;
4
5
use Muffin\Snippet;
6
7
class TableName implements Snippet
8
{
9
    private
10
        $tableName,
11
        $alias;
12
13 73
    public function __construct($tableName, $alias = null)
14
    {
15 73
        if(empty($tableName))
16 73
        {
17 6
            throw new \InvalidArgumentException('Empty table name.');
18
        }
19
20 67
        $this->tableName = $tableName;
21
22 67
        $this->alias = (string) $alias;
23 67
    }
24
25 65
    public function toString()
26
    {
27 65
        if(empty($this->alias))
28 65
        {
29 32
            return $this->tableName;
30
        }
31
32 35
        return sprintf('%s AS %s', $this->tableName, $this->alias);
33
    }
34
}
35