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 | 1 | public function update(array $attributes = []) |
|
49 | |||
50 | /** |
||
51 | * Create new tag from string of group name and tag name. |
||
52 | * |
||
53 | * @param string $tagFullName |
||
54 | * |
||
55 | * @return $this|bool |
||
56 | */ |
||
57 | 1 | public function createTagFromString($tagFullName) |
|
71 | |||
72 | /** |
||
73 | * Create a new tag if valid or return existing one. |
||
74 | * |
||
75 | * @param string $name |
||
76 | * @param null|Tag $parent |
||
77 | * |
||
78 | * @return bool|$this |
||
79 | */ |
||
80 | 1 | public function validOrCreate($name, Tag $parent = null) |
|
101 | |||
102 | /** |
||
103 | * Prepare tag details to save. |
||
104 | * |
||
105 | * @param array $input |
||
106 | * |
||
107 | * @return array |
||
108 | */ |
||
109 | 2 | protected function prepareTagToSave(array $input) |
|
120 | } |
||
121 |
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.