Core_Command::find_var PHP Method

find_var() private static method

This is equivalent to matching the \$VAR_NAME = ([^;]+) regular expression and returning the first match either as a string or as an integer (depending if it's surrounded by quotes or not).
private static find_var ( string $var_name, string $code ) : integer | string | null
$var_name string Variable name to search for.
$code string PHP code to search in.
return integer | string | null
    private static function find_var($var_name, $code)
    {
        $start = strpos($code, '$' . $var_name . ' = ');
        if (!$start) {
            return null;
        }
        $start = $start + strlen($var_name) + 3;
        $end = strpos($code, ";", $start);
        $value = substr($code, $start, $end - $start);
        if ($value[0] = "'") {
            return trim($value, "'");
        } else {
            return intval($value);
        }
    }