Using   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%
Metric Value
dl 0
loc 34
wmc 5
lcom 1
cbo 0
ccs 17
cts 17
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A toString() 0 13 2
A ensureIsArray() 0 9 2
1
<?php
2
3
namespace Muffin\Queries\Snippets;
4
5
use Muffin\Snippet;
6
7
class Using implements Snippet
8
{
9
    private
10
        $columns;
11
12 14
    public function __construct($column)
13
    {
14 14
        $this->columns = $this->ensureIsArray($column);
15 14
    }
16
17 14
    public function toString()
18
    {
19 14
        $usingColumns = implode(', ', array_filter($this->columns));
20 14
        if(empty($usingColumns))
21 14
        {
22 2
            return '';
23
        }
24
25 12
        return sprintf(
26 12
            'USING (%s)',
27
            $usingColumns
28 12
        );
29
    }
30
31 14
    private function ensureIsArray($input)
32
    {
33 14
        if(! is_array($input))
34 14
        {
35 12
            $input = array($input);
36 12
        }
37
38 14
        return $input;
39
    }
40
}
41