You are here

public function SassMixinDefinitionNode::__construct in Sassy 7.3

Same name and namespace in other branches
  1. 7 phamlp/sass/tree/SassMixinDefinitionNode.php \SassMixinDefinitionNode::__construct()

SassMixinDefinitionNode constructor.

Parameters

object source token:

Return value

SassMixinDefinitionNode

Overrides SassNode::__construct

File

phpsass/tree/SassMixinDefinitionNode.php, line 40

Class

SassMixinDefinitionNode
SassMixinDefinitionNode class. Represents a Mixin definition. @package PHamlP @subpackage Sass.tree

Code

public function __construct($token) {
  if ($token->level !== 0) {
    throw new SassMixinDefinitionNodeException('Mixins 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 Mixin', $this);
  }
  $this->name = $matches[self::NAME];
  if (isset($matches[self::ARGUMENTS])) {
    foreach (SassScriptFunction::extractArgs($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
  }
}