/** * Check if the given string is a valid operator query. * * @param string $string * @return bool */ public static function validate($string) { $string = (string) $string; $null = Factory::syntax('symbols', 'null', '-'); if (empty($string)) { return false; } return !!($string == $null || ctype_alnum($string[0]) || in_array($string[0], [Factory::syntax('symbols', 'equals', '='), Factory::syntax('symbols', 'bigger', ']'), Factory::syntax('symbols', 'smaller', '['), Factory::syntax('symbols', 'like', '~'), Factory::syntax('symbols', 'not', '!')])); }
/** * Mockery should always be closed when a test is teared down. * Also, reset the factory syntax. * * @return void */ public function tearDown() { Mockery::close(); Factory::$SYNTAX = []; }
/** * Check if the given string is a valid relation query. * * @param string $string * @return bool */ public static function validate($string) { return !!strpos($string, Factory::syntax('symbols', 'relation', ':')); }
/** * Test if the static syntax method returns the default value if an unknown syntax is requested. * * @return void */ public function testSyntaxReturnsDefaultWhenKeyIsNotDefined() { $this->assertSame('unknown', Factory::syntax('symbols', 'what??', 'unknown')); }