SassIfNode::__construct PHP Method

__construct() public method

SassIfNode constructor.
public __construct ( object $token, boolean $if = true ) : SassIfNode
$token object source token
$if boolean true for an "if" node, false for an "else if | else" node
return SassIfNode
    public function __construct($token, $if = true)
    {
        parent::__construct($token);
        if ($if) {
            preg_match(self::MATCH_IF, $token->source, $matches);
            $this->expression = $matches[SassIfNode::IF_EXPRESSION];
        } else {
            preg_match(self::MATCH_ELSE, $token->source, $matches);
            $this->expression = sizeof($matches) == 1 ? null : $matches[SassIfNode::ELSE_EXPRESSION];
        }
    }

Usage Example

Example #1
0
 /**
  * SassElseNode constructor.
  * @param object source token
  * @return SassElseNode
  */
 public function __construct($token)
 {
     parent::__construct($token, false);
 }