Passed
Push — master ( 9f58b4...83392d )
by Rougin
03:13
created

OneToOne::make()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 2
dl 0
loc 8
ccs 5
cts 5
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Rougin\Windstorm\Relation;
4
5
use Rougin\Windstorm\RelationInterface;
6
7
/**
8
 * One-To-One Relation
9
 *
10
 * @package Windstorm
11
 * @author  Rougin Gutib <[email protected]>
12
 */
13
class OneToOne extends Relation implements RelationInterface
14
{
15
    /**
16
     * Generates the query instance from relation.
17
     *
18
     * @param  string $primary
19
     * @param  string $foreign
20
     * @return \Rougin\Windstorm\QueryInterface
21
     */
22 3
    public function make($primary, $foreign)
23
    {
24 3
        $fields = array_merge($this->columns(0), $this->columns(1));
25
26 3
        $query = $this->query;
27
28 3
        return $query->select($fields)->from($this->primary, $this->alias[0])
29 3
            ->innerJoin($this->foreign, $primary, $foreign);
30
    }
31
}
32