| @@ 165-173 (lines=9) @@ | ||
| 162 | * @param string $string |
|
| 163 | * @return bool |
|
| 164 | */ |
|
| 165 | function startsWith() { |
|
| 166 | $startsWith = function($token, $string) { |
|
| 167 | return ( |
|
| 168 | strlen($token) <= strlen($string) && |
|
| 169 | substr($string, 0, strlen($token)) === $token |
|
| 170 | ); |
|
| 171 | }; |
|
| 172 | return apply(curry($startsWith), func_get_args()); |
|
| 173 | } |
|
| 174 | ||
| 175 | /** |
|
| 176 | * Checks if `$string` ends with `$token`. |
|
| @@ 188-196 (lines=9) @@ | ||
| 185 | * @param string $string |
|
| 186 | * @return bool |
|
| 187 | */ |
|
| 188 | function endsWith() { |
|
| 189 | $endsWith = function($token, $string) { |
|
| 190 | return ( |
|
| 191 | strlen($token) <= strlen($string) && |
|
| 192 | substr($string, - strlen($token)) === $token |
|
| 193 | ); |
|
| 194 | }; |
|
| 195 | return apply(curry($endsWith), func_get_args()); |
|
| 196 | } |
|
| 197 | ||
| 198 | /** |
|
| 199 | * Checks if a string matches a regular expression. |
|