| 1 | <?php |
||
| 9 | trait HasUrlFunctionsTrait |
||
| 10 | { |
||
| 11 | |||
| 12 | /** |
||
| 13 | * Get the root URL for the application. |
||
| 14 | * |
||
| 15 | * @return string |
||
| 16 | */ |
||
| 17 | public function root() |
||
| 21 | |||
| 22 | |||
| 23 | /** |
||
| 24 | * Get the full URL for the request. |
||
| 25 | * |
||
| 26 | * @return string |
||
| 27 | */ |
||
| 28 | public function fullUrl() |
||
| 34 | |||
| 35 | /** |
||
| 36 | * Get the URL (no query string) for the request. |
||
| 37 | * |
||
| 38 | * @return string |
||
| 39 | */ |
||
| 40 | public function url() |
||
| 44 | |||
| 45 | /** |
||
| 46 | * Generates a normalized URI (URL) for the Request. |
||
| 47 | * |
||
| 48 | * @return string A normalized URI (URL) for the Request |
||
| 49 | * |
||
| 50 | * @see getQueryString() |
||
| 51 | */ |
||
| 52 | public function getUri() |
||
| 60 | |||
| 61 | /** |
||
| 62 | * @return string |
||
| 63 | */ |
||
| 64 | public function getSchemeAndHttpHost() |
||
| 68 | |||
| 69 | /** |
||
| 70 | * @return string |
||
| 71 | */ |
||
| 72 | public function getHttpHost() |
||
| 83 | } |
This check looks for methods that are used by a trait but not required by it.
To illustrate, let’s look at the following code example
The trait
Idableprovides a methodequalsIdthat in turn relies on the methodgetId(). If this method does not exist on a class mixing in this trait, the method will fail.Adding the
getId()as an abstract method to the trait will make sure it is available.