Passed
Push — master ( 4b3582...7f619e )
by Julien
06:12
created

QueryBuilder   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 1 Features 0
Metric Value
wmc 5
eloc 8
dl 0
loc 34
ccs 0
cts 9
cp 0
rs 10
c 1
b 1
f 0
1
<?php
2
3
/**
4
 * This file is part of the Zemit Framework.
5
 *
6
 * (c) Zemit Team <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE.txt
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Zemit\Mvc\Model\EagerLoading;
13
14
use Phalcon\Mvc\Model\Query\Builder;
15
use Phalcon\Mvc\Model\Query\BuilderInterface;
16
17
final class QueryBuilder extends Builder
18
{
19
    public const string E_NOT_ALLOWED_METHOD_CALL = 'When eager loading relations queries must return full entities';
0 ignored issues
show
Bug introduced by
A parse error occurred: Syntax error, unexpected T_STRING, expecting '=' on line 19 at column 24
Loading history...
20
    
21
    /**
22
     * @param mixed $distinct
23
     * @return BuilderInterface
24
     * @throws \LogicException
25
     */
26
    public function distinct($distinct): BuilderInterface
27
    {
28
        throw new \LogicException(self::E_NOT_ALLOWED_METHOD_CALL);
29
    }
30
    
31
    /**
32
     * @param mixed $columns
33
     * @return BuilderInterface
34
     * @throws \LogicException
35
     */
36
    public function columns($columns): BuilderInterface
37
    {
38
        throw new \LogicException(self::E_NOT_ALLOWED_METHOD_CALL);
39
    }
40
    
41
    /**
42
     * Replacing where to andWhere in order to avoid loosing relationship conditions
43
     */
44
    public function where(string $conditions, array $bindParams = [], array $bindTypes = []): BuilderInterface
45
    {
46
        if (!empty($this->conditions)) {
47
            $appendCondition = is_array($this->conditions)? implode(') AND (', $this->conditions) : $this->conditions;
48
            $conditions = '(' . $appendCondition . ') AND (' . $conditions . ')';
49
        }
50
        return parent::where($conditions, $bindParams, $bindTypes);
51
    }
52
}
53