diff options
author | Dan Ungureanu <udan1107@gmail.com> | 2015-07-25 17:57:42 +0300 |
---|---|---|
committer | Dan Ungureanu <udan1107@gmail.com> | 2015-07-25 17:59:01 +0300 |
commit | 7861701ecf87f1e98a50258f8798f3d9abc4d12f (patch) | |
tree | 4df9440244f7966a38097ac74ed0f9dce19237f9 /src | |
parent | f1b0644ea90d427acd58aefc9d27137349fc13f3 (diff) | |
download | sql-parser-7861701ecf87f1e98a50258f8798f3d9abc4d12f.zip sql-parser-7861701ecf87f1e98a50258f8798f3d9abc4d12f.tar.gz sql-parser-7861701ecf87f1e98a50258f8798f3d9abc4d12f.tar.bz2 |
Translated exceptions.
Refactored tests.
Diffstat (limited to 'src')
-rw-r--r-- | src/Component.php | 120 |
1 files changed, 70 insertions, 50 deletions
diff --git a/src/Component.php b/src/Component.php index 3aa5506..7291ca5 100644 --- a/src/Component.php +++ b/src/Component.php @@ -10,64 +10,84 @@ * * @package SqlParser */ -namespace SqlParser; -/** - * A component (of a statement) is a part of a statement that is common to - * multiple query types. - * - * @category Components - * @package SqlParser - * @author Dan Ungureanu <udan1107@gmail.com> - * @license http://opensource.org/licenses/GPL-2.0 GNU Public License - */ -abstract class Component -{ +namespace { - /** - * Parses the tokens contained in the given list in the context of the given - * parser. - * - * @param Parser $parser The parser that serves as context. - * @param TokensList $list The list of tokens that are being parsed. - * @param array $options Parameters for parsing. - * - * @return mixed - */ - public static function parse( - Parser $parser, TokensList $list, array $options = array() - ) { - // This method should be abstract, but it can't be both static and - // abstract. - throw new \Exception('Not implemented yet.'); - } + if (!function_exists('__')) { - /** - * Builds the string representation of a component of this type. - * - * In other words, this function represents the inverse function of - * `static::parse`. - * - * @param mixed $component The component to be built. - * - * @return string - */ - public static function build($component) - { - // This method should be abstract, but it can't be both static and - // abstract. - throw new \Exception('Not implemented yet.'); + /** + * Translates the given string. + * + * @param string $str String to be translated. + * + * @return string + */ + function __($str) + { + return $str; + } } +} + +namespace SqlParser { /** - * Builds the string representation of a component of this type. - * - * @see static::build + * A component (of a statement) is a part of a statement that is common to + * multiple query types. * - * @return string + * @category Components + * @package SqlParser + * @author Dan Ungureanu <udan1107@gmail.com> + * @license http://opensource.org/licenses/GPL-2.0 GNU Public License */ - public function __toString() + abstract class Component { - return static::build($this); + + /** + * Parses the tokens contained in the given list in the context of the given + * parser. + * + * @param Parser $parser The parser that serves as context. + * @param TokensList $list The list of tokens that are being parsed. + * @param array $options Parameters for parsing. + * + * @return mixed + */ + public static function parse( + Parser $parser, TokensList $list, array $options = array() + ) { + // This method should be abstract, but it can't be both static and + // abstract. + throw new \Exception(\__('Not implemented yet.')); + } + + /** + * Builds the string representation of a component of this type. + * + * In other words, this function represents the inverse function of + * `static::parse`. + * + * @param mixed $component The component to be built. + * + * @return string + */ + public static function build($component) + { + // This method should be abstract, but it can't be both static and + // abstract. + throw new \Exception(\__('Not implemented yet.')); + } + + /** + * Builds the string representation of a component of this type. + * + * @see static::build + * + * @return string + */ + public function __toString() + { + return static::build($this); + } } } |