Total Complexity | 5 |
Total Lines | 76 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
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() |
|
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() |
|
90 | } |
||
91 | } |
||
92 |