1 | <?php |
||
13 | trait UrlFunctionTrait |
||
14 | { |
||
15 | /** |
||
16 | * Get the full URL for the current request. |
||
17 | * |
||
18 | * @return string |
||
19 | */ |
||
20 | public function full() |
||
24 | |||
25 | /** |
||
26 | * Get the current URL for the request. |
||
27 | * |
||
28 | * @return string |
||
29 | */ |
||
30 | public function current() |
||
34 | |||
35 | /** |
||
36 | * Generate an absolute URL to the given path. |
||
37 | * |
||
38 | * @param string $path |
||
39 | * @param mixed $extra |
||
40 | * @param bool|null $secure |
||
41 | * @return string |
||
42 | */ |
||
43 | public function to($path, $extra = [], $secure = null) |
||
63 | |||
64 | /** |
||
65 | * Generate the URL to an application asset. |
||
66 | * |
||
67 | * @param string $path |
||
68 | * @param bool|null $secure |
||
69 | * @return string |
||
70 | */ |
||
71 | public function asset($path, $secure = null) |
||
82 | |||
83 | /** |
||
84 | * Determine if the given path is a valid URL. |
||
85 | * |
||
86 | * @param string $path |
||
87 | * @return bool |
||
88 | */ |
||
89 | public function isValidUrl($path) |
||
96 | |||
97 | |||
98 | /** |
||
99 | * Extract the query string from the given path. |
||
100 | * |
||
101 | * @param string $path |
||
102 | * @return string[] |
||
103 | */ |
||
104 | protected function extractQueryString($path) |
||
114 | } |
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
Idable
provides a methodequalsId
that 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.