private function SassParser::getLevel in Sassy 7.3
Same name and namespace in other branches
- 7 phamlp/sass/SassParser.php \SassParser::getLevel()
Returns the level of the line. Used for .sass source
Parameters
string the source:
Return value
integer the level of the source
Throws
Exception if the source indentation is invalid
2 calls to SassParser::getLevel()
- SassParser::parseDirective in phpsass/
SassParser.php - Parses a directive
- SassParser::sass2Token in phpsass/
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 statement.
File
- phpsass/
SassParser.php, line 717
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_float($level)) {
$level = (int) ceil($level);
}
if (!is_int($level) || preg_match("/[^{$this->indentChar}]/", substr($source, 0, $indent))) {
$this->source = $source;
if ($this->debug) {
throw new SassException('Invalid indentation', $this);
}
else {
return 0;
}
}
return $level;
}