Created
November 6, 2023 10:20
-
-
Save TheSETJ/90a404d11202977b51520b4afda06049 to your computer and use it in GitHub Desktop.
A trait that helps with formatting URI
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
trait WorksWithUri | |
{ | |
private function makeFullUri($baseUri, $path) | |
{ | |
return $this->formatBaseUri($baseUri) . $this->formatRelativePath($path); | |
} | |
private function formatBaseUri($baseUri) | |
{ | |
return rtrim($baseUri, '/'); | |
} | |
private function formatRelativePath($path) | |
{ | |
return '/' . ltrim($path, '/'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment