public function SassFunctionDefinitionNode::__construct in Sassy 7.3
SassFunctionDefinitionNode constructor.
Parameters
object source token:
Return value
Overrides SassNode::__construct
File
- phpsass/
tree/ SassFunctionDefinitionNode.php, line 42
Class
- SassFunctionDefinitionNode
- SassFunctionDefinitionNode class. Represents a Function definition. @package PHamlP @subpackage Sass.tree
Code
public function __construct($token) {
if ($token->level !== 0) {
throw new SassMixinDefinitionNodeException('Functions can only be defined at root level', $this);
}
parent::__construct($token);
preg_match(self::MATCH, $token->source, $matches);
if (empty($matches)) {
throw new SassMixinDefinitionNodeException('Invalid Function', $this);
}
$this->name = $matches[self::NAME];
$this->name = preg_replace('/[^a-z0-9_]/', '_', strtolower($this->name));
if (isset($matches[self::ARGUMENTS])) {
if (strlen(trim($matches[self::ARGUMENTS]))) {
foreach (explode(',', $matches[self::ARGUMENTS]) as $arg) {
$arg = explode($matches[self::IDENTIFIER] === self::NODE_IDENTIFIER ? '=' : ':', trim($arg));
$this->args[substr(trim($arg[0]), 1)] = count($arg) == 2 ? trim($arg[1]) : null;
}
// foreach
}
}
}