You are here

private function SassParser::getLevel in Sassy 7

Same name and namespace in other branches
  1. 7.3 phpsass/SassParser.php \SassParser::getLevel()

* Returns the level of the line. * Used for .sass source *

Parameters

string the source: * @return integer the level of the source * @throws Exception if the source indentation is invalid

2 calls to SassParser::getLevel()
SassParser::parseDirective in phamlp/sass/SassParser.php
* Parses a directive *
SassParser::sass2Token in phamlp/sass/SassParser.php
* Returns an object that contains the next source statement and meta data * about it from SASS source. * Sass statements are passed over. Statements spanning multiple lines, e.g. * CSS comments and selectors, are assembled into a single…

File

phamlp/sass/SassParser.php, line 646

Class

SassParser
SassParser class. Parses {@link http://sass-lang.com/ .sass and .sccs} files. @package PHamlP @subpackage Sass

Code

private function getLevel($source) {
  $indent = strlen($source) - strlen(ltrim($source));
  $level = $indent / $this->indentSpaces;
  if (!is_int($level) || preg_match("/[^{$this->indentChar}]/", substr($source, 0, $indent))) {
    $this->source = $source;
    throw new SassException('Invalid indentation', array(), $this);
  }
  return $level;
}