SqlParser\Context::isString PHP Method

isString() public static method

Checks if the given character is the beginning of a string.
public static isString ( string $str ) : integer
$str string String to be checked.
return integer The appropriate flag for the string type.
    public static function isString($str)
    {
        if ($str[0] === '\'') {
            return Token::FLAG_STRING_SINGLE_QUOTES;
        } elseif ($str[0] === '"') {
            return Token::FLAG_STRING_DOUBLE_QUOTES;
        }
        return null;
    }

Usage Example

Example #1
0
 public function testIsString()
 {
     $this->assertEquals(Token::FLAG_STRING_SINGLE_QUOTES, Context::isString("'"));
     $this->assertEquals(Token::FLAG_STRING_DOUBLE_QUOTES, Context::isString('"'));
     $this->assertEquals(Token::FLAG_STRING_SINGLE_QUOTES, Context::isString("'foo bar'"));
     $this->assertEquals(Token::FLAG_STRING_DOUBLE_QUOTES, Context::isString('"foo bar"'));
     $this->assertEquals(Context::isString('foo bar'), null);
 }
All Usage Examples Of SqlParser\Context::isString