Skip to content

Commit 2b01c57

Browse files
committed
Factorize code in isEmptySelf()
1 parent ea51a40 commit 2b01c57

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

lib/Doctrine/DBAL/Query/Expression/CompositeExpression.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public function add($part)
7979
return $this;
8080
}
8181

82-
if ($part instanceof self && count($part) === 0) {
82+
if ($this->isEmptySelf($part)) {
8383
return $this;
8484
}
8585

@@ -100,12 +100,12 @@ public function with($part, ...$parts) : self
100100
{
101101
$that = clone $this;
102102

103-
if (! ($part instanceof self && count($part) === 0)) {
103+
if (! $this->isEmptySelf($part)) {
104104
$that->parts[] = $part;
105105
}
106106

107107
foreach ($parts as $part) {
108-
if ($part instanceof self && count($part) === 0) {
108+
if ($this->isEmptySelf($part)) {
109109
continue;
110110
}
111111

@@ -115,6 +115,14 @@ public function with($part, ...$parts) : self
115115
return $that;
116116
}
117117

118+
/**
119+
* @param self|string $part
120+
*/
121+
private function isEmptySelf($part) : bool
122+
{
123+
return $part instanceof self && count($part) === 0;
124+
}
125+
118126
/**
119127
* Retrieves the amount of expressions on composite expression.
120128
*

0 commit comments

Comments
 (0)