# code-snippets/4.0.0-beta.2/vendor/typisttech/imposter/src/StringUtil.php

Code Snippets, version 4.0.0-beta.2. 24 lines.

- Page: https://pluginprobe.com/plugins/code-snippets/4.0.0-beta.2/code/vendor/typisttech/imposter/src/StringUtil.php
- Raw: https://pluginprobe.com/plugins/code-snippets/4.0.0-beta.2/raw/vendor/typisttech/imposter/src/StringUtil.php
- Modified: 2025-10-16T19:08:06+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/code-snippets/4.0.0-beta.2/code/vendor/typisttech/imposter/src/StringUtil.php#L10-L20`.

```php
<?php

declare(strict_types=1);

namespace TypistTech\Imposter;

class StringUtil
{
    public static function addTrailingSlash(string $string): string
    {
        return rtrim($string, '/\\') . '/';
    }

    public static function ensureDoubleBackwardSlash(string $string): string
    {
        $parts = explode('\\', $string);
        $nonEmptyParts = array_filter($parts, function ($part) {
            return ! empty($part);
        });

        return implode('\\\\', $nonEmptyParts) . '\\\\';
    }
}

```
