public static function ensureLeading($needle, $haystack)
    {
        $needleLength = strlen($needle);
        $needlePart = substr($haystack, 0, $needleLength);

        if ($needlePart !== $needle) {
            // append missing trailing string
            $haystack = $needle . $haystack;
        }

        return $haystack;
    }