Transforms content of the Statement to n-quads form.

@return string N-Quads string containing subject, predicate, object and graph, if available

@throws \Exception if this instance is a non-concrete statement

@api

@since 0.1
8416
public function toNQuads()
    {
        if ($this->isConcrete()) {
            if ($this->isQuad()) {
                return $this->getSubject()->toNQuads().' '.
                       $this->getPredicate()->toNQuads().' '.
                       $this->getObject()->toNQuads().' '.
                       $this->getGraph()->toNQuads().' .';
            } else {
                return $this->getSubject()->toNQuads().' '.
                       $this->getPredicate()->toNQuads().' '.
                       $this->getObject()->toNQuads().' .';
            }
        } else {
            throw new \Exception('A Statement has to be concrete in N-Quads.');
        }
    }
982540
private function parseSubjectByWord()
    {
        $i = 0;
        $isFirstIteration = true;
        foreach (explode(' ', $this->subject) as $currentWord) {
            $delimitersMatches = [];
            $haveProcessedCurrentWord = false;

            if (preg_match_all('/' . self::REGEXP_SENTENCE_DELIMITERS . '/', $currentWord, $delimitersMatches)) {
                $this->iteratorCache->append(new TextIteratorElement(' ', $i, 1, true));

                $j = 0;
                $splittedWord = preg_split('/' . self::REGEXP_SENTENCE_DELIMITERS . '/', $currentWord);
                foreach ($splittedWord as $currentPart) {
                    if ($currentPart !== '') {
                        $this->iteratorCache->append(new TextIteratorElement($currentPart, $i, Unicode\Functions::strlen($currentPart), false));
                        $i += Unicode\Functions::strlen($currentPart);
                    }
                    if ($j < count($delimitersMatches[0])) {
                        $this->iteratorCache->append(new TextIteratorElement($delimitersMatches[0][$j], $i, 1, true));
                    }
                    $i++;
                    $j++;
                }
                $haveProcessedCurrentWord = true;
            }

            if (!$isFirstIteration && !$haveProcessedCurrentWord) {
                $this->iteratorCache->append(new TextIteratorElement(' ', $i, 1, true));
                $i++;
            } else {
                $isFirstIteration = false;
            }

            if (!$haveProcessedCurrentWord) {
                $this->iteratorCache->append(new TextIteratorElement($currentWord, $i, Unicode\Functions::strlen($currentWord), false));
                $i += Unicode\Functions::strlen($currentWord);
            }

            unset($delimitersMatches);
        }
    }
1143404
private function prepareDataBits()
    {
        $n              = $this->structureAppendN;
        $m              = $this->structureAppendM;
        $parity         = $this->structureAppendParity;
        $originalData   = $this->structureAppendOriginalData;

        $dataCounter   = 0;

        if ( $this->checkStructureAppend($n, $m) )
        {
            $dataValue[0]  = 3;
            $dataBits[0]   = 4;

            $dataValue[1]  = $m - 1;
            $dataBits[1]   = 4;

            $dataValue[2]  = $n - 1;
            $dataBits[2]   = 4;

            $originalDataLength = strlen($originalData);

            if ( $originalDataLength > 1 )
            {
                $parity = 0;

                $i      = 0;
                while ($i < $originalDataLength)
                {
                    $parity = ($parity ^ ord(substr($originalData, $i, 1)));
                    $i++;
                }
            }

            $dataValue[3]  = $parity;
            $dataBits[3]   = 8;

            $dataCounter   = 4;
        }

        $dataBits[$dataCounter] = 4;

        return $dataBits;
    }
768725
protected function buildFacetPart()
    {
        if (!$this->sqlParts['facet']) {
            return '';
        }

        $facetParts = array();
        foreach ($this->sqlParts['facet'] as $facet) {
            $facetExpressions = array();
            foreach ($facet['facet'] as $key => $facetExpr) {
                if (is_int($key)) {
                    $facetExpressions[] = $facetExpr;
                } else {
                    $facetExpressions[] = $key.' AS '.$facetExpr;
                }
            }
            $facetPart = 'FACET '.implode(', ', $facetExpressions);
            if ($facet['by']) {
                $facetPart .= ' BY '.$facet['by'];
            }
            if ($facet['order']) {
                $facetPart .= ' ORDER BY '.$facet['order'].$this->getDirection($facet['order'], $facet['direction']);
            }
            if ($facet['limit']) {
                $facetPart .= ' LIMIT '.(int) $facet['skip'].', '.(int) $facet['limit'];
            }

            $facetParts[] = $facetPart;
        }

        return ' '.implode(' ', $facetParts);
    }
341243
public function asString()
    {
        $tmp = new \SplTempFileObject;

        foreach ($this->data as $row) {
            $tmp->fputcsv($row, $this->delimiter);

            if ($this->lineEnding !== "\n") {
                $tmp->fseek(-1, \SEEK_CUR);
                $tmp->fwrite($this->lineEnding);
            }
        }

        # Find out how much data we have written
        $length = $tmp->ftell();
        if ($length < 1) {
            return "";
        }

        # Reset the internal pointer and return all the data we have written
        $tmp->fseek(0);
        return $tmp->fread($length);
    }
1220222
public function getStatement()
	{
		return (is_object($this->statement))
				? $this->interpolate($this->statement->queryString, $this->bindings)
				: $this->statement;
	}
1194585
protected function buildCols()
    {
        if (!$this->cols) {
            throw new Exception('No columns in the SELECT.');
        }

        $cols = array();
        foreach ($this->cols as $key => $val) {
            if (is_int($key)) {
                $cols[] = $this->quoteNamesIn($val);
            } else {
                $cols[] = $this->quoteNamesIn("$val AS $key");
            }
        }

        return $this->indentCsv($cols);
    }
835912
public function getNextAddress()
    {
        $overflow = false;
        $words = $this->getWords();
        for ($i = count($words) - 1; $i >= 0; --$i) {
            if ($words[$i] === 0xffff) {
                if ($i === 0) {
                    $overflow = true;
                    break;
                }
                $words[$i] = 0;
            } else {
                ++$words[$i];
                break;
            }
        }

        return $overflow ? null : static::fromWords($words);
    }
1210077
public function from()
    {
        $from = '';

        $numargs = func_num_args();

        if ($this->oosql_del_multiFlag) {


            if ($numargs < $this->oosql_del_numargs) {
                $msg = 'Columns and passed data do not match! ' . $this->sql();
                throw new \Exception($msg, 9810, null);
            }


        }

        $from .= ' FROM ';

        $from .= $this->oosql_table;

        if ($numargs > 0) {
            $from .= ', ';

            $arg_list = func_get_args();

            for ($i = 0; $i < $numargs; $i++) {
                if ($i !== 0 && $numargs > $i) {
                    $from .= ', ';
                }

                if ($arg_list[$i] instanceof oosql) {

                    $arg_list[$i]->alias();
                    $fields = $arg_list[$i]->getFields($arg_list[$i]->getTableAlias());

                    $this->sql(',' . implode(', ', $fields));
                    $from .= $arg_list[$i]->getSql() . ' AS ' . $arg_list[$i]->getTableAlias();
                } else {
                    $from .= $arg_list[$i];
                }
            }
        }

        $this->sql($from);

        $this->oosql_fromFlag = false;

        return $this;
    }
696106
public function getDescription()
    {
        if ($this->max !== -1) {
            return vsprintf(
                'The value is expected to have a length between %d and %d'
                . ' (%d <= x <= %d).',
                [
                    $this->min,
                    $this->max,
                    $this->min,
                    $this->max,
                ]
            );
        }

        return vsprintf(
            'The value is expected to have a length greater or equal to %d'
            . ' (%d <= x).',
            [
                $this->min,
                $this->min,
            ]
        );
    }
505661
public function getStatement()
    {
        return $this->_fixBlanks(
            trim(
                str_replace(
                    array(
                        '<fields>', '<joinFields>', '<tableName>',
                        '<joins>', '<where>', '<groupBy>',
                        '<orderBy>', '<limit>'
                    ),
                    array(
                        $this->getFields(),
                        $this->getJoinFields(),
                        $this->_sql->getTableName(),
                        $this->getJoins(), 
                        $this->getWhere(),
                        $this->getGroupBy(),
                        $this->getOrderBy(),
                        $this->getLimit()
                    ),
                    $this->_select
                )
            )
        );
    }
926644
public function toArray()
	{
		$a = array();
		$nodes = $this->getNodes();
		for( $i=0; $i<$this->getNodeSize(); $i++ )
		{
			$source = $nodes[$i];
			$line = array();
			for( $j=0; $j<$this->getNodeSize(); $j++ )
			{
				$target = $nodes[$j];
				$value = $this->getEdgeValue( $source, $target );
				$line[$target->getNodeName()] = $value;
			}
			$a[$source->getNodeName()] = $line;
		}
		return $a;
	}
73105
private function getNewUseStatements(): string
    {
        $this->sortUseStatements();

        $file = $this->getFile()->getBaseFile();

        return implode(
            $file->eolChar,
            array_map(
                function (UseStatement $useStatement) use ($file): string {
                    $unqualifiedName = NamespaceHelper::getUnqualifiedNameFromFullyQualifiedName(
                        $useStatement->getFullyQualifiedTypeName()
                    );

                    $useTypeName = UseStatementHelper::getTypeName($file, $useStatement);
                    $useTypeFormatted = $useTypeName ? sprintf('%s ', $useTypeName) : '';

                    return ($unqualifiedName === $useStatement->getNameAsReferencedInFile())
                        ? sprintf(
                            'use %s%s;',
                            $useTypeFormatted,
                            $useStatement->getFullyQualifiedTypeName()
                        )
                        : sprintf(
                            'use %s%s as %s;',
                            $useTypeFormatted,
                            $useStatement->getFullyQualifiedTypeName(),
                            $useStatement->getNameAsReferencedInFile()
                        );
                },
                $this->useStatements
            )
        );
    }
598603
public function getSql()
    {
        if ($this->isEmpty()) {
            throw new Exception("Invalid segment, please specify a valid segment.");
        }
        $sql = '';
        $subExpression = false;
        foreach ($this->tree as $expression) {
            $operator = $expression[self::INDEX_BOOL_OPERATOR];
            $operand = $expression[self::INDEX_OPERAND];

            if ($operator == self::BOOL_OPERATOR_OR
                && !$subExpression
            ) {
                $sql .= ' (';
                $subExpression = true;
            } else {
                $sql .= ' ';
            }

            $sql .= $operand;

            if ($operator == self::BOOL_OPERATOR_AND
                && $subExpression
            ) {
                $sql .= ')';
                $subExpression = false;
            }

            $sql .= " $operator";
        }
        if ($subExpression) {
            $sql .= ')';
        }
        return array(
            'where' => $sql,
            'bind'  => $this->valuesBind,
            'join'  => implode(' ', $this->joins)
        );
    }
348387
private function exception1()
    {
        $exceptions = array(
            'skis'   => 'ski',
            'skies'  => 'sky',
            'dying'  => 'die',
            'lying'  => 'lie',
            'tying'  => 'tie',
            'idly'   => 'idl',
            'gently' => 'gentl',
            'ugly'   => 'ugli',
            'early'  => 'earli',
            'only'   => 'onli',
            'singly' => 'singl',
            // invariants
            'sky'    => 'sky',
            'news'   => 'news',
            'howe'   => 'howe',
            'atlas'  => 'atlas',
            'cosmos' => 'cosmos',
            'bias'   => 'bias',
            'andes'  => 'andes'
        );

        if (isset($exceptions[$this->word])) {
            return $exceptions[$this->word];
        }

        return null;
    }
217203
public function getStatement()
    {
        $cql = '';

        if (!$this->getFrom() || !$this->getWhere()) {
            throw new \Exception('Delete statement must contain from and where values');
        }

        $cql .= $this->getType().$this->getColumns().' FROM '.$this->getFrom().' WHERE '.$this->getWhere();

        if ($this->isIfExists()) {
            $cql .= ' IF EXISTS';
        }

        return $cql;
    }
1359349
private function parseAddition (){

		$return = $m = $this->parseMultiplication();
		if( $return ){
			while( true ){

				$isSpaced = $this->isWhitespace( -1 );

				$op = $this->MatchReg('/\\G[-+]\s+/');
				if( $op ){
					$op = $op[0];
				}else{
					if( !$isSpaced ){
						$op = $this->match(array('#+','#-'));
					}
					if( !$op ){
						break;
					}
				}

				$a = $this->parseMultiplication();
				if( !$a ){
					break;
				}

				$m->parensInOp = true;
				$a->parensInOp = true;
				$return = $this->NewObj3('Less_Tree_Operation',array($op, array($return, $a), $isSpaced));
			}
		}

		return $return;
	}