Completed
Pull Request — master (#256)
by Tomáš
02:41
created

InlineParamsQueryBuilder::innerJoin()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 13
rs 9.2
cc 4
eloc 8
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 InlineParamsQueryBuilder extends Kdyby\Doctrine\QueryBuilder
23
{
24
25
	/**
26
	 * {@inheritdoc}
27
	 * @return InlineParamsQueryBuilder
28
	 */
29
	public function join($join, $alias, $conditionType = NULL, $condition = NULL, $indexBy = NULL)
30
	{
31
		return call_user_func_array([$this, 'innerJoin'], func_get_args());
32
	}
33
34
35
36
	/**
37
	 * {@inheritdoc}
38
	 * @return InlineParamsQueryBuilder
39
	 */
40
	public function innerJoin($join, $alias, $conditionType = NULL, $condition = NULL, $indexBy = NULL)
41
	{
42
		if ($condition !== NULL) {
43
			$beforeArgs = array_slice(func_get_args(), 3);
44
			$args = array_values(Helpers::separateParameters($this, $beforeArgs));
45
			if (count($beforeArgs) > count($args)) {
46
				$indexBy = count($args) === 2 ? $args[1] : NULL;
47
				$condition = $args[0];
48
			}
49
		}
50
51
		return parent::innerJoin($join, $alias, $conditionType, $condition, $indexBy);
52
	}
53
54
55
56
	/**
57
	 * {@inheritdoc}
58
	 * @return InlineParamsQueryBuilder
59
	 */
60
	public function leftJoin($join, $alias, $conditionType = NULL, $condition = NULL, $indexBy = NULL)
61
	{
62
		if ($condition !== NULL) {
63
			$beforeArgs = array_slice(func_get_args(), 3);
64
			$args = array_values(Helpers::separateParameters($this, $beforeArgs));
65
			if (count($beforeArgs) > count($args)) {
66
				$indexBy = count($args) === 2 ? $args[1] : NULL;
67
				$condition = $args[0];
68
			}
69
		}
70
71
		return parent::leftJoin($join, $alias, $conditionType, $condition, $indexBy);
72
	}
73
74
75
76
	/**
77
	 * {@inheritdoc}
78
	 * @return InlineParamsQueryBuilder
79
	 */
80
	public function where($predicates)
81
	{
82
		return call_user_func_array('parent::where', Helpers::separateParameters($this, func_get_args()));
83
	}
84
85
86
87
	/**
88
	 * {@inheritdoc}
89
	 * @return InlineParamsQueryBuilder
90
	 */
91
	public function andWhere()
92
	{
93
		return call_user_func_array('parent::andWhere', Helpers::separateParameters($this, func_get_args()));
94
	}
95
96
97
98
	/**
99
	 * {@inheritdoc}
100
	 * @return InlineParamsQueryBuilder
101
	 */
102
	public function orWhere()
103
	{
104
		return call_user_func_array('parent::orWhere', Helpers::separateParameters($this, func_get_args()));
105
	}
106
107
}
108