1 | <?php |
||
19 | trait Transactionable |
||
20 | { |
||
21 | /** |
||
22 | * Create a new entity with the given attributes. |
||
23 | * |
||
24 | * @param array $attributes |
||
25 | * |
||
26 | * @return array |
||
27 | * @throws \Exception |
||
28 | */ |
||
29 | public function create(array $attributes = []) |
||
45 | |||
46 | /** |
||
47 | * Update an entity with the given attributes. |
||
48 | * |
||
49 | * @param mixed $id |
||
50 | * @param array $attributes |
||
51 | * |
||
52 | * @return array |
||
53 | * @throws \Exception |
||
54 | */ |
||
55 | public function update($id, array $attributes = []) |
||
71 | |||
72 | /** |
||
73 | * Delete an entity with the given id. |
||
74 | * |
||
75 | * @param mixed $id |
||
76 | * |
||
77 | * @return array |
||
78 | * @throws \Exception |
||
79 | */ |
||
80 | public function delete($id) |
||
96 | } |
||
97 |
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.