You are here

public function SassMixinDefinitionNode::__construct in Sassy 7

Same name and namespace in other branches
  1. 7.3 phpsass/tree/SassMixinDefinitionNode.php \SassMixinDefinitionNode::__construct()

* SassMixinDefinitionNode constructor. *

Parameters

object source token: * @return SassMixinDefinitionNode

Overrides SassNode::__construct

File

phamlp/sass/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', array(), $this);
  }
  parent::__construct($token);
  preg_match(self::MATCH, $token->source, $matches);
  if (empty($matches)) {
    throw new SassMixinDefinitionNodeException('Invalid {what}', array(
      '{what}' => 'Mixin',
    ), $this);
  }
  $this->name = $matches[self::NAME];
  if (isset($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
  }
}