1 | <?php namespace BuildR\Utils; |
||
15 | class StringUtils { |
||
16 | |||
17 | /** |
||
18 | * Determines that the given string starts with the |
||
19 | * given substring |
||
20 | * |
||
21 | * @param string $input |
||
22 | * @param string $match |
||
23 | * |
||
24 | * @return bool |
||
25 | */ |
||
26 | 5 | public static function startsWith($input, $match) { |
|
27 | 5 | return ($match !== '' && mb_strpos($input, $match) === 0); |
|
28 | } |
||
29 | |||
30 | /** |
||
31 | * Determines that the given string ends with the |
||
32 | * given substring |
||
33 | * |
||
34 | * @param string $input |
||
35 | * @param string $match |
||
36 | * |
||
37 | * @return bool |
||
38 | */ |
||
39 | 5 | public static function endsWith($input, $match) { |
|
40 | 5 | return ((string) $match === mb_substr($input, (mb_strlen($match) * -1))); |
|
41 | } |
||
42 | |||
43 | /** |
||
44 | * Determines that the input string contains the |
||
45 | * given substring. |
||
46 | * |
||
47 | * @param string $input |
||
48 | * @param string $match |
||
49 | * |
||
50 | * @return bool |
||
51 | */ |
||
52 | 7 | public static function contains($input, $match) { |
|
55 | |||
56 | /** |
||
57 | * At this time PHP MBString extension does not have a mulibyte version |
||
58 | * of the PHP's ucfirst() method. This is a simple implementation. |
||
59 | * |
||
60 | * @param string $input |
||
61 | * |
||
62 | * @return string |
||
63 | */ |
||
64 | 10 | public static function multiByteUcfirst($input) { |
|
70 | |||
71 | /** |
||
72 | *At this time PHP MBString extension does not have a mulibyte version |
||
73 | * of the PHP's ucwords() method. This is a simple implementation. |
||
74 | * |
||
75 | * This function has a very big limitation against PHP native implementation, |
||
76 | * this function only split string trough spaces instead of any whitespace |
||
77 | * character |
||
78 | * |
||
79 | * @param $input |
||
80 | */ |
||
81 | 4 | public static function multiByteUcwords($input) { |
|
87 | |||
88 | } |
||
89 |