@@ 72-96 (lines=25) @@ | ||
69 | * |
|
70 | * @return TokenRegistry |
|
71 | */ |
|
72 | public function run($input) |
|
73 | { |
|
74 | if ($input instanceof TokenRegistry) { |
|
75 | // Tokenize a TokenRegistry |
|
76 | $f = clone($input); |
|
77 | foreach ($input as $token) { |
|
78 | if (! $token instanceof WordToken) { |
|
79 | continue; |
|
80 | } |
|
81 | $newTokens = $this->tokenize($token->get()); |
|
82 | $f->replace($token, $newTokens); |
|
83 | } |
|
84 | ||
85 | return $f ; |
|
86 | } |
|
87 | ||
88 | // Tokenize a simple string. |
|
89 | $array = $this->tokenize($input); |
|
90 | $registry = new TokenRegistry(); |
|
91 | foreach ($array as $item) { |
|
92 | $registry->add($item); |
|
93 | } |
|
94 | ||
95 | return $registry; |
|
96 | } |
|
97 | ||
98 | /** |
|
99 | * Split the given string into tokens using whitespace. |
@@ 109-136 (lines=28) @@ | ||
106 | * |
|
107 | * @return TokenRegistry |
|
108 | */ |
|
109 | public function run($input) |
|
110 | { |
|
111 | if ($input instanceof TokenRegistry) { |
|
112 | // Tokenize a TokenRegistry |
|
113 | $f = clone($input); |
|
114 | foreach ($input as $token) { |
|
115 | if (! $token instanceof WordToken) { |
|
116 | continue; |
|
117 | } |
|
118 | $newTokens = $this->tokenize($token->get()); |
|
119 | if ($newTokens == array($token)) { |
|
120 | continue; |
|
121 | } |
|
122 | $f->replace($token, $newTokens); |
|
123 | } |
|
124 | ||
125 | return $f ; |
|
126 | } |
|
127 | ||
128 | // Tokenize a simple string. |
|
129 | $array = $this->tokenize($input); |
|
130 | $registry = new TokenRegistry(); |
|
131 | foreach ($array as $item) { |
|
132 | $registry->add($item); |
|
133 | } |
|
134 | ||
135 | return $registry; |
|
136 | } |
|
137 | ||
138 | /** |
|
139 | * Split the given string into tokens using whitespace. |
@@ 62-88 (lines=27) @@ | ||
59 | * |
|
60 | * @return TokenRegistry |
|
61 | */ |
|
62 | public function run($input) |
|
63 | { |
|
64 | if ($input instanceof TokenRegistry) { |
|
65 | // Tokenize a TokenRegistry |
|
66 | foreach ($input as $token) { |
|
67 | if (! $token instanceof WordToken) { |
|
68 | continue; |
|
69 | } |
|
70 | $newTokens = $this->tokenize($token->get()); |
|
71 | if ($newTokens == array($token)) { |
|
72 | continue; |
|
73 | } |
|
74 | $input->replace($token, $newTokens); |
|
75 | } |
|
76 | ||
77 | return $input ; |
|
78 | } |
|
79 | ||
80 | // Tokenize a simple string. |
|
81 | $array = $this->tokenize($input); |
|
82 | $registry = new TokenRegistry(); |
|
83 | foreach ($array as $item) { |
|
84 | $registry->add($item); |
|
85 | } |
|
86 | ||
87 | return $registry; |
|
88 | } |
|
89 | ||
90 | /** |
|
91 | * Split the given string into tokens using whitespace. |
@@ 71-97 (lines=27) @@ | ||
68 | * |
|
69 | * @return TokenRegistry |
|
70 | */ |
|
71 | public function run($input) |
|
72 | { |
|
73 | if ($input instanceof TokenRegistry) { |
|
74 | // Tokenize a TokenRegistry |
|
75 | foreach ($input as $token) { |
|
76 | if (! $token instanceof WordToken) { |
|
77 | continue; |
|
78 | } |
|
79 | $newTokens = $this->tokenize($token->get()); |
|
80 | if ($newTokens == array($token)) { |
|
81 | continue; |
|
82 | } |
|
83 | $input->replace($token, $newTokens); |
|
84 | } |
|
85 | ||
86 | return $input ; |
|
87 | } |
|
88 | ||
89 | // Tokenize a simple string. |
|
90 | $array = $this->tokenize($input); |
|
91 | $registry = new TokenRegistry(); |
|
92 | foreach ($array as $item) { |
|
93 | $registry->add($item); |
|
94 | } |
|
95 | ||
96 | return $registry; |
|
97 | } |
|
98 | ||
99 | /** |
|
100 | * Split the given string into tokens using whitespace. |