| Total Complexity | 5 |
| Total Lines | 50 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 10 | class Url { |
||
| 11 | /** |
||
| 12 | * Return the current path relative to the home url |
||
| 13 | * |
||
| 14 | * @return string |
||
| 15 | */ |
||
| 16 | 2 | public static function getCurrentPath( Request $request ) { |
|
| 17 | 2 | $url = $request->getUrl(); |
|
| 18 | 2 | $relative_url = substr( $url, strlen( home_url( '/' ) ) ); |
|
| 19 | 2 | return static::addTrailingSlash( static::addLeadingSlash( $relative_url ) ); |
|
| 20 | } |
||
| 21 | |||
| 22 | /** |
||
| 23 | * Ensure url has a leading slash |
||
| 24 | * |
||
| 25 | * @param string $url |
||
| 26 | * @return string |
||
| 27 | */ |
||
| 28 | 3 | public static function addLeadingSlash( $url ) { |
|
| 29 | 3 | return '/' . static::removeLeadingSlash( $url ); |
|
| 30 | } |
||
| 31 | |||
| 32 | /** |
||
| 33 | * Ensure url does not have a leading slash |
||
| 34 | * |
||
| 35 | * @param string $url |
||
| 36 | * @return string |
||
| 37 | */ |
||
| 38 | 4 | public static function removeLeadingSlash( $url ) { |
|
| 40 | } |
||
| 41 | |||
| 42 | /** |
||
| 43 | * Ensure url has a trailing slash |
||
| 44 | * |
||
| 45 | * @param string $url |
||
| 46 | * @return string |
||
| 47 | */ |
||
| 48 | 3 | public static function addTrailingSlash( $url ) { |
|
| 50 | } |
||
| 51 | |||
| 52 | /** |
||
| 53 | * Ensure url does not have a trailing slash |
||
| 54 | * |
||
| 55 | * @param string $url |
||
| 56 | * @return string |
||
| 57 | */ |
||
| 58 | 1 | public static function removeTrailingSlash( $url ) { |
|
| 62 |