On::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1
Metric Value
dl 0
loc 5
ccs 4
cts 4
cp 1
rs 9.4286
cc 1
eloc 3
nc 1
nop 2
crap 1
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