1 | <?php |
||
7 | trait Columns |
||
8 | { |
||
9 | |||
10 | /** |
||
11 | * Check if any document within the table has the column. |
||
12 | * |
||
13 | * @param string|array $column |
||
14 | * @return Fluent |
||
15 | */ |
||
16 | public function hasColumn($column) |
||
25 | |||
26 | /** |
||
27 | * Indicate that the given attributes should be renamed. |
||
28 | * |
||
29 | * @param string $from |
||
30 | * @param string $to |
||
31 | * @return Fluent |
||
32 | */ |
||
33 | public function renameColumn($from, $to) |
||
43 | |||
44 | |||
45 | /** |
||
46 | * Indicate that the given column(s) should be dropped. |
||
47 | * |
||
48 | * @param array|mixed $columns |
||
49 | * @return Fluent |
||
50 | */ |
||
51 | public function dropColumn($columns) |
||
62 | |||
63 | } |
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.