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

Child::query()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
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\ChildInterface;
6
use Rougin\Windstorm\QueryInterface;
7
8
/**
9
 * Child
10
 *
11
 * @package Windstorm
12
 * @author  Rougin Gutib <[email protected]>
13
 */
14
class Child extends Wrappable implements ChildInterface
15
{
16
    /**
17
     * @var string
18
     */
19
    protected $field = '';
20
21
    /**
22
     * @var string
23
     */
24
    protected $foreign = '';
25
26
    /**
27
     * @var string
28
     */
29
    protected $primary = '';
30
31
    /**
32
     * Initializes the child query instance.
33
     *
34
     * @param string                           $field
35
     * @param \Rougin\Windstorm\QueryInterface $query
36
     * @param string                           $primary
37
     * @param string                           $foreign
38
     */
39 6
    public function __construct($field, QueryInterface $query, $primary, $foreign)
40
    {
41 6
        parent::__construct($query);
42
43 6
        $this->field = $field;
44
45 6
        $this->foreign = $foreign;
46
47 6
        $this->primary = $primary;
48 6
    }
49
50
    /**
51
     * Returns the field to store the result from the
52
     * child query instance and append it to the result
53
     * from the parent query instance as a single value.
54
     *
55
     * @return string
56
     */
57 6
    public function field()
58
    {
59 6
        return $this->field;
60
    }
61
62
    /**
63
     * Returns the identifier column from the child table.
64
     *
65
     * @return string
66
     */
67 6
    public function foreign()
68
    {
69 6
        return $this->foreign;
70
    }
71
72
    /**
73
     * Returns the identifier column from the parent table.
74
     *
75
     * @return string
76
     */
77 6
    public function primary()
78
    {
79 6
        return $this->primary;
80
    }
81
82
    /**
83
     * Returns the specified query instance.
84
     *
85
     * @return \Rougin\Windstorm\QueryInterface
86
     */
87 6
    public function query()
88
    {
89 6
        return $this->query;
90
    }
91
}
92