server/src/app/Libraries/Utils.php
changeset 329 0a2c2ad49d75
parent 261 02e2396bcbbc
child 386 c731ab9b934d
--- a/server/src/app/Libraries/Utils.php	Thu Oct 13 13:01:12 2016 +0200
+++ b/server/src/app/Libraries/Utils.php	Fri Oct 14 01:02:10 2016 +0200
@@ -134,4 +134,26 @@
         return new Graph($graph1->getUri(), $merged, 'php');
     }
 
+    /**
+     * From http://stackoverflow.com/a/834355
+     */
+    public static function startsWith($haystack, $needle)
+    {
+        $length = strlen($needle);
+        return (substr($haystack, 0, $length) === $needle);
+    }
+
+    /**
+     * From http://stackoverflow.com/a/834355
+     */
+    public static function endsWith($haystack, $needle)
+    {
+        $length = strlen($needle);
+        if ($length == 0) {
+            return true;
+        }
+
+        return (substr($haystack, -$length) === $needle);
+    }
+
 }