Appends GROUP BY statement

@param string|array $target
@throws \InvalidArgumentException If $target isn't either a string or an array
@return \Krystal\Db\Sql\QueryBuilder
180474
public function groupBy($target)
    {
        $columns = null;

        if (is_string($target)) {
            $columns = $target;

        } elseif (is_array($target)) {
            $columns = implode(', ', $target);

        } else {
            throw new InvalidArgumentException(sprintf(
                'groupBy() accepts only an array of columns or a plain column name. You supplied "%s"', gettype($target)
            ));
        }

        $this->append(sprintf(' GROUP BY %s ', $columns));
        return $this;
    }
1140649
public function addIndex($index)
    {
        if ($index instanceof Index) {
            if ($this->hasIndex($index->getName())) {
                throw new InvalidArgumentException(sprintf('Index "%s" already exist.', $index->getName()));
            }
            if (!$index->getColumns()) {
                throw new InvalidArgumentException(sprintf('Index "%s" has no columns.', $index->getName()));
            }
            $index->setTable($this);
            // force the name to be created if empty.
            $this->indices[] = $index;

            return $index;
        }

        $idx = new Index();
        $idx->loadMapping($index);
        foreach((array)@$index['columns'] as $column) {
            $idx->addColumn($column);
        }

        return $this->addIndex($idx);
    }
883195
protected function applySearchTermFilterToQueryBuilder($query, $target, $search)
    {
        // Make sure we have a target to work with
        $target = $target ?: $query->getModel()->getKeyName();

        $this->applyFilterStrategyToQuery($query, $target, $search);

        return $this;
    }
277713
public function count($target, $alias = null)
    {
        $this->queryBuilder->count($target, $alias);
        return $this;
    }
311853
public function setTarget($target)
    {
        if (!$target instanceof ModelInterface) {
            throw new Exception\InvalidArgumentException(sprintf(
                '"%s" works only with ModelInterface targets',
                __CLASS__
            ));
        }
        return parent::setTarget($target);
    }
378317
protected function cookieMatchesTarget ($cookie, $target)
    {
        if (!is_array($target)) {
            throw new CAS_InvalidArgumentException(
                '$target must be an array of URL attributes as generated by parse_url().'
            );
        }
        if (!isset($target['host'])) {
            throw new CAS_InvalidArgumentException(
                '$target must be an array of URL attributes as generated by parse_url().'
            );
        }

        // Verify that the scheme matches
        if ($cookie['secure'] && $target['scheme'] != 'https') {
            return false;
        }

        // Verify that the host matches
        // Match domain and mulit-host cookies
        if (strpos($cookie['domain'], '.') === 0) {
            // .host.domain.edu cookies are valid for host.domain.edu
            if (substr($cookie['domain'], 1) == $target['host']) {
                // continue with other checks
            } else {
                // non-exact host-name matches.
                // check that the target host a.b.c.edu is within .b.c.edu
                $pos = strripos($target['host'], $cookie['domain']);
                if (!$pos) {
                    return false;
                }
                // verify that the cookie domain is the last part of the host.
                if ($pos + strlen($cookie['domain']) != strlen($target['host'])) {
                    return false;
                }
                // verify that the host name does not contain interior dots as per
                // RFC 2965 section 3.3.2  Rejecting Cookies
                // http://www.ietf.org/rfc/rfc2965.txt
                $hostname = substr($target['host'], 0, $pos);
                if (strpos($hostname, '.') !== false) {
                    return false;
                }
            }
        } else {
            // If the cookie host doesn't begin with '.',
            // the host must case-insensitive match exactly
            if (strcasecmp($target['host'], $cookie['domain']) !== 0) {
                return false;
            }
        }

        // Verify that the port matches
        if (isset($cookie['ports'])
            && !in_array($target['port'], $cookie['ports'])
        ) {
            return false;
        }

        // Verify that the path matches
        if (strpos($target['path'], $cookie['path']) !== 0) {
            return false;
        }

        return true;
    }
327768
public function addTargetGroup(TargetGroupInterface $targetGroup)
    {
        $fileVersion = $this->getFileVersion();
        $fileVersion->addTargetGroup($targetGroup);

        return $this;
    }
860888
protected function mapJoinColumns(array $target = [], array $source = [])
    {
        $joinColumns = [];
        foreach ($target as $index => $joinColumn) {
            if (isset($source[$index])) {
                $diff = array_diff($joinColumn, $source[$index]);

                if (!empty($diff)) {
                    $joinColumns[] = $diff;
                }
            }
        }

        return $joinColumns;
    }
1354613
public function add(InstallTarget $target)
    {
        $this->targets[$target->getName()] = $target;

        if (!$this->defaultTarget) {
            $this->defaultTarget = $target;
        }
    }
456520
public function prependTo($target)
    {
        $target_result = $this->getTargetResult($target);

        $target_result->prepend($this);
        $this->remove();

        return $target_result;
    }
703215
protected function addItemToTarget(array &$target, array $item, $first=false, $createGroup=false)
	{
		if(is_array($item['attributes'])) {
			$attributes = '';

			foreach($item['attributes'] as $attribute) {
				// do not assign empty attributes
				if($attribute['name'] == '') {
					continue;
				}

				if($attribute['name'] == 'class' && !isset($item['class'])) {
					$item['class'] = $attribute ['value'];
					continue;
				}

				$attributes .= $attributes ? ' ' : '';
				$attributes .= $attribute['name'] . '="' . $attribute ['value'] . '"';

			}

			$item['attributes'] = $attributes;
		}

		// make sure every key is set
		$item = array_merge(array(
				'type'      => '',
				'button'    => 'link',
				'attributes'=> '',
				'url'       => '',
				'label'     => ''
			), $item
		);


		if($first)
		{
			if($createGroup && isset($target[0]) && $target[0]['type'] == 'group')
			{
				$item = array('type' => 'group', 'items' => array($item));
			}

			$target = array_merge(array($item), $target);
			return;
		}

		if($createGroup)
		{
			$end = end($this->arrButtons);

			if($end !== false && $end['type'] == 'group')
			{
				$item = array('type' => 'group', 'items' => array($item));
			}
		}

		$target[] = $item;
	}
282914
public function rename($source, $target)
    {
        if ($source instanceof NodeObject) {
            if (!$source->isBlob()) {
                throw new \InvalidArgumentException("The given object is not a blob, it couldn't be renamed");
            }
            $sourceName = $source->getFullPath();
        } else {
            $sourceName = $source;
        }
        $this->clearAll();
        $this->addCommandName(self::MV_COMMAND);
        // Skip move or rename actions which would lead to an error condition
        $this->addCommandArgument('-k');
        $this->addCommandSubject($sourceName);
        $this->addCommandSubject2($target);

        return $this->getCommand();
    }
860784
public function setTarget($target)
    {
        if (!file_exists(dirname($target))) {
            throw new Exception\InvalidArgumentException("The directory '$target' does not exist");
        }

        $target = str_replace(['/', '\\'], DIRECTORY_SEPARATOR, (string) $target);
        $this->options['target'] = $target;
        return $this;
    }
522386
public function groupBy($field): QueryBuilderInterface
	{
		if ( ! is_scalar($field))
		{
			$newGroupArray = array_map([$this->driver, 'quoteIdent'], $field);
			$this->state->setGroupArray(
				array_merge($this->state->getGroupArray(), $newGroupArray)
			);
		}
		else
		{
			$this->state->appendGroupArray($this->driver->quoteIdent($field));
		}

		$this->state->setGroupString(' GROUP BY ' . implode(',', $this->state->getGroupArray()));

		return $this;
	}
1175401
public function copy($target, $source)
    {
        if (!$this->exists($target)) {
            throw new \RuntimeException("$target does not exist.", E_ERROR);
        }

        if (!$this->exists($source)) {
            $this->makeDirectory(dirname($source), true);
        }

        return file_put_contents($source, $this->get($target));
    }
780670
private function addAllRecursive($source, $target, array $path = [])
    {
        foreach ($source as $key => $value)
        {
            if (!isset($target[$key]))
            {
                $target[$key] = $value;
            }
            else
            {
                $tgt = $target[$key];

                if (is_array($source) || $source instanceof Dictionary)
                {
                    if ($tgt instanceof Dictionary)
                        $this->addAllRecursive($value, $tgt);
                    else
                        $target[$key] = $value;
                }
                else
                    $target[$key] = $value;
            }
        }
    }
1330854
public function preserialise ($target, array $args = array()) {

        # Include default args, but allow passed ones to override them
        $args = array_merge($this -> default_args, $args);

        # Serialise an array containing the target
        $result = self::serialiseIterable(array($target), $args, $this -> max_depth, 0);
        return array_shift($result);
    }