1 | <?php |
||
24 | trait CrudTrait |
||
25 | { |
||
26 | /** |
||
27 | * Create a new tag. |
||
28 | * |
||
29 | * @param array $input |
||
30 | * |
||
31 | * @return mixed |
||
32 | */ |
||
33 | 1 | public function createTag(array $input) |
|
37 | |||
38 | /** |
||
39 | * Update the tags in the database. |
||
40 | * |
||
41 | * @param array $attributes |
||
42 | * |
||
43 | * @return bool|int |
||
44 | */ |
||
45 | public function update(array $attributes = []) |
||
49 | |||
50 | /** |
||
51 | * Create a new tag if valid or return existing one. |
||
52 | * |
||
53 | * @param string $name |
||
54 | * @param null|Tag $parent |
||
55 | * |
||
56 | * @return bool|$this |
||
57 | */ |
||
58 | public function validOrCreate($name, Tag $parent = null) |
||
79 | |||
80 | /** |
||
81 | * Prepare tag details to save. |
||
82 | * |
||
83 | * @param array $input |
||
84 | * |
||
85 | * @return array |
||
86 | */ |
||
87 | protected function prepareTagToSave(array $input) |
||
93 | } |
||
94 |
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.