1 | <?php |
||
25 | trait CrudTrait |
||
26 | { |
||
27 | /** |
||
28 | * Create a new tag. |
||
29 | * |
||
30 | * @param array $input |
||
31 | * |
||
32 | * @return mixed |
||
33 | 1 | */ |
|
34 | public function createTag(array $input) |
||
38 | |||
39 | /** |
||
40 | * Update the tags in the database. |
||
41 | * |
||
42 | * @param array $attributes |
||
43 | * |
||
44 | * @return bool|int |
||
45 | */ |
||
46 | public function update(array $attributes = []) |
||
50 | |||
51 | /** |
||
52 | * Create a new tag if valid or return existing one. |
||
53 | * |
||
54 | * @param string $name |
||
55 | * @param null|Tag $parent |
||
56 | * |
||
57 | * @return bool|$this |
||
58 | */ |
||
59 | public function validOrCreate($name, Tag $parent = null) |
||
80 | |||
81 | /** |
||
82 | * Delete tag. |
||
83 | * |
||
84 | * @return bool|null |
||
85 | * |
||
86 | * @throws \Exception |
||
87 | */ |
||
88 | public function delete() |
||
98 | |||
99 | /** |
||
100 | * Prepare tag details to save. |
||
101 | * |
||
102 | * @param array $input |
||
103 | * |
||
104 | * @return array |
||
105 | */ |
||
106 | protected function prepareTagToSave(array $input) |
||
112 | } |
||
113 |
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.