-
Notifications
You must be signed in to change notification settings - Fork 0
/
Formatting.php
40 lines (32 loc) · 918 Bytes
/
Formatting.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
/**
* Qubus\Routing
*
* @link https://github.com/QubusPHP/router
* @copyright 2020
* @author Joshua Parker <[email protected]>
* @license https://opensource.org/licenses/mit-license.php MIT License
*/
declare(strict_types=1);
namespace Qubus\Routing;
use function ltrim;
use function rtrim;
final class Formatting
{
public static function removeTrailingSlash(string $input): string
{
return rtrim(string: $input, characters: '/\\');
}
public static function addTrailingSlash(string $input): string
{
return self::removeTrailingSlash(input: $input) . '/';
}
public static function removeLeadingSlash(string $input): string
{
return ltrim(string: $input, characters: '/\\');
}
public static function addLeadingSlash(string $input): string
{
return '/' . self::removeLeadingSlash(input: $input);
}
}