Total Complexity | 2 |
Total Lines | 30 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
23 | class StringUtils extends AbstractStdlib |
||
24 | { |
||
25 | /** |
||
26 | * Return true, if needle is at the beginning of haystack |
||
27 | * |
||
28 | * @param string $haystack |
||
29 | * @param string $needle |
||
30 | * |
||
31 | * @return bool |
||
32 | */ |
||
33 | 10 | public static function startsWith(string $haystack, string $needle): bool |
|
34 | { |
||
35 | 10 | $len = strlen($needle); |
|
36 | |||
37 | 10 | return ($needle === substr($haystack, 0, $len)); |
|
38 | } |
||
39 | |||
40 | /** |
||
41 | * Return true, if needle is at the end of haystack |
||
42 | * |
||
43 | * @param string $haystack |
||
44 | * @param string $needle |
||
45 | * |
||
46 | * @return bool |
||
47 | */ |
||
48 | 11 | public static function endsWith(string $haystack, string $needle): bool |
|
53 | } |
||
54 | } |
||
55 |