<commit_before><?php

namespace Colibri\Query\Expr\Func;

use Colibri\Query\Expr\Func;

/**
 * Class GroupConcat
 * @package Colibri\Query\Expr\Func
 */
class GroupConcat extends Func
{
  
  /**
   * @var string
   */
  private $separator;
  
  /**
   * @var string
   */
  private $orderVector;
  
  /**
   * GroupConcat constructor.
   * @param array ...$parameters
   */
  public function __construct(...$parameters)
  {
    parent::__construct('GROUP_CONCAT', $parameters);
  }
  
  /**
   * @return string
   */
  public function getSeparator()
  {
    return $this->separator;
  }
  
  /**
   * @param string $separator
   * @return $this
   */
  public function setSeparator($separator)
  {
    $this->separator = $separator;
    
    return $this;
  }
  
  /**
   * @return string
   */
  public function getOrderVector()
  {
    return $this->orderVector;
  }
  
  /**
   * @param string $orderVector
   * @return $this
   */
  public function setOrderVector($orderVector)
  {
    $this->orderVector = $orderVector;
  
    return $this;
  }
  
  /**
   * @inheritdoc
   */
  protected function toStringFunctionArguments()
  {
    $arguments = parent::toStringFunctionArguments();
  
    if (null !== $this->getOrderVector()) {
      $arguments = sprintf("%s ORDER BY %s", $arguments, $this->getOrderVector());
    }
  
    if (null !== $this->getSeparator()) {
      $arguments = sprintf("%s SEPARATOR '%s'", $arguments, $this->getSeparator());
    }
    
    return $arguments;
  }
  
}
<commit_msg>Update GroupConcat.php<commit_after><?php

namespace Colibri\Query\Expr\Func;

use Colibri\Query\Expr\Column;
use Colibri\Query\Expr\Func;
use Colibri\Query\Expression;
use Colibri\Query\Statement\OrderBy;

/**
 * Class GroupConcat
 * @package Colibri\Query\Expr\Func
 */
class GroupConcat extends Func
{
  
  /**
   * @var bool
   */
  private $isDistinct = false;
  
  /**
   * @var string
   */
  private $separator;
  
  /**
   * @var Expression
   */
  private $expression;
  
  /**
   * @var string
   */
  private $vector;
  
  /**
   * GroupConcat constructor.
   * @param array ...$parameters
   */
  public function __construct(...$parameters)
  {
    parent::__construct('GROUP_CONCAT', $parameters);
  }
  
  /**
   * @return bool
   */
  public function isDistinct()
  {
    return $this->isDistinct;
  }
  
  /**
   * @param bool $isDistinct
   * @return $this
   */
  public function setDistinct($isDistinct)
  {
    $this->isDistinct = $isDistinct;
    
    return $this;
  }
  
  /**
   * @return string
   */
  public function getSeparator()
  {
    return $this->separator;
  }
  
  /**
   * @param string $separator
   * @return $this
   */
  public function setSeparator($separator)
  {
    $this->separator = $separator;
    
    return $this;
  }
  
  /**
   * @param $expression
   * @param string $vector
   * @return $this
   */
  public function setOrderBy($expression, $vector = OrderBy::ASC)
  {
    if (!($expression instanceof Expression)) {
      $expression = new Column($expression);
    }
    
    $this->setExpression($expression)->setVector($vector);
  
    return $this;
  }
  
  /**
   * @return Expression
   */
  public function getExpression()
  {
    return $this->expression;
  }
  
  /**
   * @param Expression $expression
   * @return $this
   */
  public function setExpression(Expression $expression)
  {
    $this->expression = $expression;
    
    return $this;
  }
  
  /**
   * @return string
   */
  public function getVector()
  {
    return $this->vector;
  }
  
  /**
   * @param string $vector
   * @return $this
   */
  public function setVector($vector)
  {
    $this->vector = $vector;
    
    return $this;
  }
  
  /**
   * @return $this
   */
  public function removeOrderBy()
  {
    $this->vector = $this->expression = null;
    
    return $this;
  }
  
  /**
   * @inheritdoc
   */
  protected function toStringFunctionArguments()
  {
    $arguments = parent::toStringFunctionArguments();
  
    if (true === $this->isDistinct()) {
      $arguments = sprintf('DISTINCT %s', $arguments);
    }
  
    if ($this->getExpression() instanceof Expression) {
      $orderBy = new OrderBy($this->getBuilder());
      $orderBy->order($this->getExpression(), $this->getVector());
      $arguments = sprintf("%s ORDER BY %s", $arguments, $orderBy->toSQL());
    }
  
    if (null !== $this->getSeparator()) {
      $arguments = sprintf("%s SEPARATOR '%s'", $arguments, $this->getSeparator());
    }
    
    return $arguments;
  }
  
}

{'fraction_non_alphanumeric': 0.15411947590495226, 'fraction_numerical': 0.0, 'mean_word_length': 2.5023328149300155, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 32, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3006928', 'n_tokens_mistral': 1493, 'n_tokens_neox': 1494, 'n_words': 292}