|
10 | 10 | * |
11 | 11 | * @package SqlParser |
12 | 12 | */ |
13 | | -namespace SqlParser; |
14 | 13 |
|
15 | | -/** |
16 | | - * A component (of a statement) is a part of a statement that is common to |
17 | | - * multiple query types. |
18 | | - * |
19 | | - * @category Components |
20 | | - * @package SqlParser |
21 | | - * @author Dan Ungureanu <udan1107@gmail.com> |
22 | | - * @license http://opensource.org/licenses/GPL-2.0 GNU Public License |
23 | | - */ |
24 | | -abstract class Component |
25 | | -{ |
| 14 | +namespace { |
26 | 15 |
|
27 | | - /** |
28 | | - * Parses the tokens contained in the given list in the context of the given |
29 | | - * parser. |
30 | | - * |
31 | | - * @param Parser $parser The parser that serves as context. |
32 | | - * @param TokensList $list The list of tokens that are being parsed. |
33 | | - * @param array $options Parameters for parsing. |
34 | | - * |
35 | | - * @return mixed |
36 | | - */ |
37 | | - public static function parse( |
38 | | - Parser $parser, TokensList $list, array $options = array() |
39 | | - ) { |
40 | | - // This method should be abstract, but it can't be both static and |
41 | | - // abstract. |
42 | | - throw new \Exception('Not implemented yet.'); |
43 | | - } |
| 16 | + if (!function_exists('__')) { |
44 | 17 |
|
45 | | - /** |
46 | | - * Builds the string representation of a component of this type. |
47 | | - * |
48 | | - * In other words, this function represents the inverse function of |
49 | | - * `static::parse`. |
50 | | - * |
51 | | - * @param mixed $component The component to be built. |
52 | | - * |
53 | | - * @return string |
54 | | - */ |
55 | | - public static function build($component) |
56 | | - { |
57 | | - // This method should be abstract, but it can't be both static and |
58 | | - // abstract. |
59 | | - throw new \Exception('Not implemented yet.'); |
| 18 | + /** |
| 19 | + * Translates the given string. |
| 20 | + * |
| 21 | + * @param string $str String to be translated. |
| 22 | + * |
| 23 | + * @return string |
| 24 | + */ |
| 25 | + function __($str) |
| 26 | + { |
| 27 | + return $str; |
| 28 | + } |
60 | 29 | } |
| 30 | +} |
| 31 | + |
| 32 | +namespace SqlParser { |
61 | 33 |
|
62 | 34 | /** |
63 | | - * Builds the string representation of a component of this type. |
64 | | - * |
65 | | - * @see static::build |
| 35 | + * A component (of a statement) is a part of a statement that is common to |
| 36 | + * multiple query types. |
66 | 37 | * |
67 | | - * @return string |
| 38 | + * @category Components |
| 39 | + * @package SqlParser |
| 40 | + * @author Dan Ungureanu <udan1107@gmail.com> |
| 41 | + * @license http://opensource.org/licenses/GPL-2.0 GNU Public License |
68 | 42 | */ |
69 | | - public function __toString() |
| 43 | + abstract class Component |
70 | 44 | { |
71 | | - return static::build($this); |
| 45 | + |
| 46 | + /** |
| 47 | + * Parses the tokens contained in the given list in the context of the given |
| 48 | + * parser. |
| 49 | + * |
| 50 | + * @param Parser $parser The parser that serves as context. |
| 51 | + * @param TokensList $list The list of tokens that are being parsed. |
| 52 | + * @param array $options Parameters for parsing. |
| 53 | + * |
| 54 | + * @return mixed |
| 55 | + */ |
| 56 | + public static function parse( |
| 57 | + Parser $parser, TokensList $list, array $options = array() |
| 58 | + ) { |
| 59 | + // This method should be abstract, but it can't be both static and |
| 60 | + // abstract. |
| 61 | + throw new \Exception(\__('Not implemented yet.')); |
| 62 | + } |
| 63 | + |
| 64 | + /** |
| 65 | + * Builds the string representation of a component of this type. |
| 66 | + * |
| 67 | + * In other words, this function represents the inverse function of |
| 68 | + * `static::parse`. |
| 69 | + * |
| 70 | + * @param mixed $component The component to be built. |
| 71 | + * |
| 72 | + * @return string |
| 73 | + */ |
| 74 | + public static function build($component) |
| 75 | + { |
| 76 | + // This method should be abstract, but it can't be both static and |
| 77 | + // abstract. |
| 78 | + throw new \Exception(\__('Not implemented yet.')); |
| 79 | + } |
| 80 | + |
| 81 | + /** |
| 82 | + * Builds the string representation of a component of this type. |
| 83 | + * |
| 84 | + * @see static::build |
| 85 | + * |
| 86 | + * @return string |
| 87 | + */ |
| 88 | + public function __toString() |
| 89 | + { |
| 90 | + return static::build($this); |
| 91 | + } |
72 | 92 | } |
73 | 93 | } |
0 commit comments