fields = is_array($fields) ? $fields : [ $fields ]; return $this; } public function add($fields) : self { if ( is_array($fields) ) { $this->fields = array_merge($this->fields, $fields); } else { $this->fields[] = $fields; } return $this; } public function render() : string { foreach($this->fields as $key => &$value) { if ( ! is_numeric($key) ) { $value = sprintf(static::FIELD_AS, $value, $key); } } return $this->renderSegments([ ( $this->union ? 'UNION' : false ), static::SQL_TOKEN, ( $this->distinct ? 'DISTINCT' : false ), ( $this->top ? sprintf('TOP (%s)', $this->top) : false ), implode(', ', $this->fields) ]); } }