]> git.immae.eu Git - github/shaarli/Shaarli.git/blobdiff - application/Utils.php
Fix startsWith and endsWith case
[github/shaarli/Shaarli.git] / application / Utils.php
index 5b8ca508576a94b0bafd0a6ee957a99fd3a7588e..da521cceff728376178f11fe9fea0dae121d46eb 100644 (file)
@@ -41,8 +41,14 @@ function smallHash($text)
 
 /**
  * Tells if a string start with a substring
+ *
+ * @param string $haystack Given string.
+ * @param string $needle   String to search at the beginning of $haystack.
+ * @param bool   $case     Case sensitive.
+ *
+ * @return bool True if $haystack starts with $needle.
  */
-function startsWith($haystack, $needle, $case=true)
+function startsWith($haystack, $needle, $case = true)
 {
     if ($case) {
         return (strcmp(substr($haystack, 0, strlen($needle)), $needle) === 0);
@@ -52,8 +58,14 @@ function startsWith($haystack, $needle, $case=true)
 
 /**
  * Tells if a string ends with a substring
+ *
+ * @param string $haystack Given string.
+ * @param string $needle   String to search at the end of $haystack.
+ * @param bool   $case     Case sensitive.
+ *
+ * @return bool True if $haystack ends with $needle.
  */
-function endsWith($haystack, $needle, $case=true)
+function endsWith($haystack, $needle, $case = true)
 {
     if ($case) {
         return (strcmp(substr($haystack, strlen($haystack) - strlen($needle)), $needle) === 0);