public static function SassScriptFunction::extractArgs in Sassy 7
Same name and namespace in other branches
- 7.3 phpsass/script/SassScriptFunction.php \SassScriptFunction::extractArgs()
2 calls to SassScriptFunction::extractArgs()
- SassMixinNode::__construct in phamlp/
sass/ tree/ SassMixinNode.php - * SassMixinDefinitionNode constructor. *
- SassScriptLexer::lex in phamlp/
sass/ script/ SassScriptLexer.php - * Lex an expression into SassScript tokens. *
File
- phamlp/
sass/ script/ SassScriptFunction.php, line 125
Class
- SassScriptFunction
- SassScriptFunction class. Preforms a SassScript function. @package PHamlP @subpackage Sass.script
Code
public static function extractArgs($string) {
$args = array();
$arg = '';
$paren = 0;
$strpos = 0;
$strlen = strlen($string);
while ($strpos < $strlen) {
$c = $string[$strpos++];
switch ($c) {
case '(':
$paren += 1;
$arg .= $c;
break;
case ')':
$paren -= 1;
$arg .= $c;
break;
case '"':
case "'":
$arg .= $c;
do {
$_c = $string[$strpos++];
$arg .= $_c;
} while ($_c !== $c);
break;
case ',':
if ($paren) {
$arg .= $c;
break;
}
$args[] = trim($arg);
$arg = '';
break;
default:
$arg .= $c;
break;
}
}
if ($arg != '') {
$args[] = trim($arg);
}
return $args;
}