1 | <?php |
||
10 | trait AssetTrait |
||
11 | { |
||
12 | /** |
||
13 | * @return mixed |
||
14 | */ |
||
15 | 21 | public function assets() |
|
19 | |||
20 | /** |
||
21 | * @param string $type |
||
22 | * @param string|null $locale |
||
23 | * @return bool |
||
24 | */ |
||
25 | 4 | public function hasFile($type = '', $locale = null): bool |
|
31 | |||
32 | /** |
||
33 | * @param string $type |
||
34 | * @param string|null $locale |
||
35 | * @return string |
||
36 | */ |
||
37 | 6 | public function getFilename($type = '', $locale = null): string |
|
41 | |||
42 | /** |
||
43 | * @param string $type |
||
44 | * @param string $size |
||
45 | * @param string|null $locale |
||
46 | * @return string |
||
47 | */ |
||
48 | 17 | public function getFileUrl($type = '', $size = '', $locale = null): ?string |
|
67 | |||
68 | /** |
||
69 | * Adds a file to this model, accepts a type and locale to be saved with the file. |
||
70 | * |
||
71 | * @param $file |
||
72 | * @param $type |
||
73 | * @param string|null $locale |
||
74 | */ |
||
75 | 8 | public function addFile($file, $type = '', $locale = null): void |
|
84 | |||
85 | /** |
||
86 | * Adds multiple files to this model, accepts a type and locale to be saved with the file. |
||
87 | * |
||
88 | * @param $files |
||
89 | * @param $type |
||
90 | * @param string|null $locale |
||
91 | */ |
||
92 | 3 | public function addFiles($files, $type = '', $locale = null): void |
|
101 | |||
102 | /** |
||
103 | * @return mixed |
||
104 | */ |
||
105 | public function getAllImages() |
||
113 | |||
114 | /** |
||
115 | * Removes an asset completely. |
||
116 | * |
||
117 | * @param $ids |
||
118 | */ |
||
119 | 1 | public function deleteAsset($ids): void |
|
123 | |||
124 | /** |
||
125 | * Remove the asset and attaches a new one. |
||
126 | * |
||
127 | * @param $replace |
||
128 | * @param $with |
||
129 | */ |
||
130 | 1 | public function replace($replace, $with): void |
|
137 | |||
138 | /** |
||
139 | * @param null $type |
||
140 | * @param string|null $locale |
||
141 | * @return mixed |
||
142 | */ |
||
143 | 4 | public function getAllFiles($type = null, $locale = null) |
|
151 | |||
152 | /** |
||
153 | * @param string|null $locale |
||
154 | * @return string |
||
155 | */ |
||
156 | 20 | private function normalizeLocale($locale = null): string |
|
162 | } |
||
163 |
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.