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 9
CRAP Score 3
Metric Value
dl 0
loc 13
ccs 9
cts 9
cp 1
rs 9.4286
cc 3
eloc 7
nc 2
nop 0
crap 3
1
<?php
2
3
namespace Muffin\Queries\Snippets;
4
5
use Muffin\Snippet;
6
7
class On implements Snippet
8
{
9
    private
10
        $leftColumn,
11
        $rightColumn;
12
13 24
    public function __construct($leftColumn, $rightColumn)
14
    {
15 24
        $this->leftColumn = (string) $leftColumn;
16 24
        $this->rightColumn = (string) $rightColumn;
17 24
    }
18
19 24
    public function toString()
20
    {
21 24
        if(empty($this->leftColumn) || empty($this->rightColumn))
22 24
        {
23 6
            return '';
24
        }
25
26 18
        return sprintf(
27 18
            'ON %s = %s',
28 18
            $this->leftColumn,
29 18
            $this->rightColumn
30 18
        );
31
    }
32
}
33