Conditions | 3 |
Paths | 1 |
Total Lines | 25 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
13 | protected static function bootLogsActivity() |
||
14 | { |
||
15 | collect(static::eventsToBeRecorded())->each(function ($eventName) { |
||
16 | |||
17 | return static::$eventName(function (Model $model) use ($eventName) { |
||
18 | |||
19 | $description = $model->getDescriptionForEvent($eventName); |
||
20 | |||
21 | if ($description == '') { |
||
22 | return; |
||
23 | } |
||
24 | |||
25 | $extraProperties = []; |
||
26 | if ($eventName != 'deleted') { |
||
27 | $extraProperties['changes'] = $model->getChangedValues(); |
||
28 | } |
||
29 | |||
30 | app(ActivityLogger::class) |
||
31 | ->performedOn($model) |
||
32 | ->withExtraProperties($extraProperties) |
||
33 | ->log($description); |
||
34 | }); |
||
35 | |||
36 | }); |
||
37 | } |
||
38 | |||
65 |
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.