Completed
Pull Request — master (#3836)
by Benjamin
64:22
created

QueryParts   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 60
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
eloc 21
c 1
b 0
f 0
dl 0
loc 60
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __clone() 0 18 6
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Doctrine\DBAL\Query;
6
7
use Doctrine\DBAL\Query\Expression\CompositeExpression;
8
9
/**
10
 * @internal
11
 */
12
class QueryParts
13
{
14
    /** @var string[] */
15
    public $select = [];
16
17
    /** @var bool */
18
    public $distinct = false;
19
20
    /** @var From[] */
21
    public $from = [];
22
23
    /** @var string|null */
24
    public $table;
25
26
    /**
27
     * Lists of joins indexed by from alias.
28
     *
29
     * @var array<string, Join[]>
30
     */
31
    public $join = [];
32
33
    /** @var string[] */
34
    public $set = [];
35
36
    /** @var CompositeExpression|null */
37
    public $where = null;
38
39
    /** @var string[] */
40
    public $groupBy = [];
41
42
    /** @var CompositeExpression|null */
43
    public $having = null;
44
45
    /** @var string[] */
46
    public $orderBy = [];
47
48
    /** @var array<string, mixed> */
49
    public $values = [];
50
51
    /**
52
     * Deep clone of all expression objects in the SQL parts.
53
     */
54
    public function __clone()
55
    {
56
        foreach ($this->from as $key => $from) {
57
            $this->from[$key] = clone $from;
58
        }
59
60
        foreach ($this->join as $fromAlias => $joins) {
61
            foreach ($joins as $key => $join) {
62
                $this->join[$fromAlias][$key] = clone $join;
63
            }
64
        }
65
66
        if ($this->where !== null) {
67
            $this->where = clone $this->where;
68
        }
69
70
        if ($this->having !== null) {
71
            $this->having = clone $this->having;
72
        }
73
    }
74
}
75