App Engine Python SDK version 1.8.9
[gae.git] / python / php / sdk / google / appengine / util / string_util.php
blobbd287f4799956635b9429600d214ea6b6d9c8f07
1 <?php
2 /**
3 * Copyright 2007 Google Inc.
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 /**
18 * Various utilities for working with Strings.
21 namespace google\appengine\util;
23 final class StringUtil {
24 /**
25 * Return true if the first paramater contains the second parameter at the
26 * end.
28 * @param string $input The input string which may contain the suffix.
29 * @param string $suffix The string to look for at the end of the input.
31 * @return boolean <code>true</code> iff the input contains the suffix at the
32 * end.
34 public static function endsWith($input, $suffix) {
35 return substr($input, -strlen($suffix)) === $suffix;
38 /**
39 * @param string $input The string which may contain the prefix at the start.
40 * @param string $prefix The string to look for at the start of the input.
42 * @return boolean <code>true</code> iff the input contains the prefix at the
43 * start.
45 public static function startsWith($input, $prefix) {
46 return substr($input, 0, strlen($prefix)) === $prefix;
49 /**
50 * @param string $input The string which may not be url safe.
52 * @return string A Base64 encoded url safe string.
54 public static function base64UrlEncode($input) {
55 return strtr(base64_encode($input), '+/=', '-_,');
58 /**
59 * @param string $input The url safe Base64 encoded string.
61 * @return string The original string which may not be url safe.
63 public static function base64UrlDecode($input) {
64 return base64_decode(strtr($input, '-_,', '+/='));