InlineParamsBuilder::leftJoin()   A
last analyzed

Complexity

Conditions 4
Paths 4

Size

Total Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 14
rs 9.7998
c 0
b 0
f 0
cc 4
nc 4
nop 5
1
<?php
2
3
/**
4
 * This file is part of the Kdyby (http://www.kdyby.org)
5
 *
6
 * Copyright (c) 2008 Filip Procházka ([email protected])
7
 *
8
 * For the full copyright and license information, please view the file license.txt that was distributed with this source code.
9
 */
10
11
namespace Kdyby\Doctrine\Dql;
12
13
use Kdyby;
14
use Kdyby\Doctrine\Helpers;
15
use Nette;
16
17
18
19
/**
20
 * @author Filip Procházka <[email protected]>
21
 */
22
class InlineParamsBuilder extends Kdyby\Doctrine\QueryBuilder
23
{
24
25
	/**
26
	 * {@inheritdoc}
27
	 * @return InlineParamsBuilder
28
	 */
29
	public function join($join, $alias, $conditionType = NULL, $condition = NULL, $indexBy = NULL)
30
	{
31
		call_user_func_array([$this, 'innerJoin'], func_get_args());
32
		return $this;
33
	}
34
35
36
37
	/**
38
	 * {@inheritdoc}
39
	 * @return InlineParamsBuilder
40
	 */
41
	public function innerJoin($join, $alias, $conditionType = NULL, $condition = NULL, $indexBy = NULL)
42
	{
43
		if ($condition !== NULL) {
44
			$beforeArgs = array_slice(func_get_args(), 3);
45
			$args = array_values(Helpers::separateParameters($this, $beforeArgs));
46
			if (count($beforeArgs) > count($args)) {
47
				$indexBy = count($args) === 2 ? $args[1] : NULL;
48
				$condition = $args[0];
49
			}
50
		}
51
52
		parent::innerJoin($join, $alias, $conditionType, $condition, $indexBy);
53
		return $this;
54
	}
55
56
57
58
	/**
59
	 * {@inheritdoc}
60
	 * @return InlineParamsBuilder
61
	 */
62
	public function leftJoin($join, $alias, $conditionType = NULL, $condition = NULL, $indexBy = NULL)
63
	{
64
		if ($condition !== NULL) {
65
			$beforeArgs = array_slice(func_get_args(), 3);
66
			$args = array_values(Helpers::separateParameters($this, $beforeArgs));
67
			if (count($beforeArgs) > count($args)) {
68
				$indexBy = count($args) === 2 ? $args[1] : NULL;
69
				$condition = $args[0];
70
			}
71
		}
72
73
		parent::leftJoin($join, $alias, $conditionType, $condition, $indexBy);
74
		return $this;
75
	}
76
77
78
79
	/**
80
	 * {@inheritdoc}
81
	 * @return InlineParamsBuilder
82
	 */
83
	public function where($predicates)
84
	{
85
		call_user_func_array('parent::where', Helpers::separateParameters($this, func_get_args()));
86
		return $this;
87
	}
88
89
90
91
	/**
92
	 * {@inheritdoc}
93
	 * @return InlineParamsBuilder
94
	 */
95
	public function andWhere()
96
	{
97
		call_user_func_array('parent::andWhere', Helpers::separateParameters($this, func_get_args()));
98
		return $this;
99
	}
100
101
102
103
	/**
104
	 * {@inheritdoc}
105
	 * @return InlineParamsBuilder
106
	 */
107
	public function orWhere()
108
	{
109
		call_user_func_array('parent::orWhere', Helpers::separateParameters($this, func_get_args()));
110
		return $this;
111
	}
112
113
}
114