public static function startsWith($needle, $haystack, $caseSensitive = true)
    {
        if (!self::isValid($needle)) {
            return false;
        }

        list($needle, $haystack) = self::transformCase($needle, $haystack, $caseSensitive);

        if ($needle === false) {
            return false;
        } else {
            return (self::substring($haystack, 0, self::length($needle)) === $needle);
        }
    }