You are here

public static function SassScriptFunction::isa in Sassy 7.3

Same name and namespace in other branches
  1. 7 phamlp/sass/script/SassScriptFunction.php \SassScriptFunction::isa()

Returns a value indicating if a token of this type can be matched at the start of the subject string.

Parameters

string the subject string:

Return value

mixed match at the start of the string or false if no match

1 call to SassScriptFunction::isa()
SassScriptLexer::lex in phpsass/script/SassScriptLexer.php
Lex an expression into SassScript tokens.

File

phpsass/script/SassScriptFunction.php, line 144

Class

SassScriptFunction
SassScriptFunction class. Preforms a SassScript function. @package PHamlP @subpackage Sass.script

Code

public static function isa($subject) {
  if (!preg_match(self::MATCH, $subject, $matches)) {
    return false;
  }
  $match = $matches[0];
  $paren = 1;
  $strpos = strlen($match);
  $strlen = strlen($subject);
  $subject_str = (string) $subject;
  while ($paren && $strpos < $strlen) {
    $c = $subject_str[$strpos++];
    $match .= $c;
    if ($c === '(') {
      $paren += 1;
    }
    elseif ($c === ')') {
      $paren -= 1;
    }
  }
  return $match;
}