SassPropertyNode::match PHP Method

match() public static method

Returns the matches for this type of node.
public static match ( object $token, string $syntax ) : array
$token object
$syntax string the property syntax being used
return array matches
    public static function match($token, $syntax)
    {
        switch ($syntax) {
            case 'scss':
                preg_match(self::MATCH_PROPERTY_SCSS, $token->source, $matches);
                break;
            case 'new':
                preg_match(self::MATCH_PROPERTY_NEW, $token->source, $matches);
                break;
            case 'old':
                preg_match(self::MATCH_PROPERTY_OLD, $token->source, $matches);
                break;
            default:
                if (preg_match(self::MATCH_PROPERTY_NEW, $token->source, $matches) == 0) {
                    preg_match(self::MATCH_PROPERTY_OLD, $token->source, $matches);
                }
                break;
        }
        return $matches;
    }

Usage Example

Beispiel #1
0
 /**
  * Parses a property
  * @param string line to parse
  * @return SassPropertyNode property node
  */
 private function parseProperty($line)
 {
     $matches = SassPropertyNode::match($line, $this->options['property_syntax']);
     return new SassPropertyNode($matches[SassPropertyNode::NAME], $matches[SassPropertyNode::VALUE], $matches[SassPropertyNode::SCRIPT] === SassPropertyNode::IS_SCRIPT);
 }