1 | <?php |
||
11 | trait MergeTagsRecordTrait |
||
12 | { |
||
13 | use MailMergeTagsRecordTrait { |
||
14 | generateMergeTags as generateMergeTagsTrait; |
||
15 | } |
||
16 | |||
17 | /** |
||
18 | * @param $vars |
||
19 | * @return $this |
||
20 | */ |
||
21 | 2 | public function setVars($vars) |
|
31 | |||
32 | /** |
||
33 | * @return array |
||
34 | */ |
||
35 | public function getVars() |
||
39 | |||
40 | /** |
||
41 | * @inheritdoc |
||
42 | * Used to decode html entities to proper chars |
||
43 | */ |
||
44 | protected function generateMergeTags() |
||
45 | { |
||
46 | $mergeTags = $this->generateMergeTagsTrait(); |
||
47 | $mergeTags = array_map( |
||
48 | function ($item) { |
||
49 | return is_string($item) ? html_entity_decode($item, ENT_QUOTES) : $item; |
||
50 | }, |
||
51 | $mergeTags |
||
52 | ); |
||
53 | |||
54 | return $mergeTags; |
||
55 | } |
||
56 | } |
||
57 |
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.