src/QueryFormatter.php
public function format( $sparql ) {
		$this->formattedParts = array();
		$this->indentationLevel = 0;
		$this->replacements = array();

		$regexHelper = new RegexHelper();
		$sparql = $regexHelper->escapeSequences( $sparql, $this->replacements );

		foreach ( $this->split( $sparql ) as $part ) {
			if ( !empty( $this->formattedParts ) ) {
				$this->before( $part );
			}

			$this->indentation( $part );
			$this->append( $part );
			$this->after( $part );
		}

		$this->trimEnd();
		$this->formattedParts[] = "\n";

		return strtr( implode( $this->formattedParts ), $this->replacements );
	}
public function format( $sparql ) {
		$this->formattedParts = array();
		$this->indentationLevel = 0;
		$this->replacements = array();

		$regexHelper = new RegexHelper();
		$sparql = $regexHelper->escapeSequences( $sparql, $this->replacements );

		foreach ( $this->split( $sparql ) as $part ) {
			if ( !empty( $this->formattedParts ) ) {
				$this->before( $part );
			}

			$this->indentation( $part );
			$this->append( $part );
			$this->after( $part );
		}

		$this->trimEnd();
		$this->formattedParts[] = "\n";

		return strtr( implode( $this->formattedParts ), $this->replacements );
	}
public function format ( $ sparql ) { $ this -> formattedParts = array ( ) ; $ this -> indentationLevel = 0 ; $ this -> replacements = array ( ) ; $ regexHelper = new RegexHelper ( ) ; $ sparql = $ regexHelper -> escapeSequences ( $ sparql , $ this -> replacements ) ; foreach ( $ this -> split ( $ sparql ) as $ part ) { if ( ! empty ( $ this -> formattedParts ) ) { $ this -> before ( $ part ) ; } $ this -> indentation ( $ part ) ; $ this -> append ( $ part ) ; $ this -> after ( $ part ) ; } $ this -> trimEnd ( ) ; $ this -> formattedParts [ ] = "\n" ; return strtr ( implode ( $ this -> formattedParts ) , $ this -> replacements ) ; }
Formats the given SPARQL string.
Note that there have to be spaces before and after brackets and dots.

@param string $sparql
@return string
Formats the given SPARQL string . Note that there have to be spaces before and after brackets and dots .