1 | <?php |
||
10 | trait ContractTrait |
||
11 | { |
||
12 | use EmbeddableTrait; |
||
13 | |||
14 | public function behaviors() |
||
23 | |||
24 | abstract protected function slugBehaviorConfig(): array; |
||
25 | |||
26 | protected function curiesBehaviorConfig(): array |
||
30 | |||
31 | protected function getSlugBehaviorId(): string |
||
35 | |||
36 | protected function getCuriesBehaviorId(): string |
||
40 | |||
41 | public function getSlugBehavior(): Slug |
||
45 | |||
46 | public function getCuriesBehavior(): Curies |
||
50 | |||
51 | public function getSelfLink(): string |
||
55 | |||
56 | public function getLinks() |
||
61 | } |
||
62 |
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.