parts = $parts; $this->type = $type; $this->pattern = $pattern; } /** * @inheritdoc */ public function __toString() { $parts = []; foreach ($this->parts as $part) { if ($part instanceof Select) { $parts[] = sprintf('(%s)', $part->assemble()); } else { $parts[] = $part; } } $sql = implode($parts, $this->type); if ($this->pattern) { return sprintf($this->pattern, $sql); } return $sql; } }