| Conditions | 2 |
| Paths | 2 |
| Total Lines | 26 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 28 | protected function getSaveRules(): array |
||
| 29 | { |
||
| 30 | if ($discussion = app(DiscussionService::class)->getDiscussion()) { |
||
| 31 | $currentCount = $discussion->images()->count(); |
||
| 32 | } else { |
||
| 33 | $currentCount = 0; |
||
| 34 | } |
||
| 35 | |||
| 36 | return [ |
||
| 37 | 'Free' => [ |
||
| 38 | 'discussion' => 'required|string', |
||
| 39 | ], |
||
| 40 | 'Premium' => [ |
||
| 41 | 'discussion' => 'string', |
||
| 42 | 'url' => 'url', |
||
| 43 | 'images' => 'array|max:'.(1 - $currentCount), |
||
| 44 | 'images.*' => 'base64image', |
||
| 45 | ], |
||
| 46 | 'PremiumPlus' => [ |
||
| 47 | 'discussion' => 'string', |
||
| 48 | 'url' => 'url', |
||
| 49 | 'images' => 'array|max:'.(5 - $currentCount), |
||
| 50 | 'images.*' => 'base64image', |
||
| 51 | ], |
||
| 52 | ][auth()->user()->account->level]; |
||
| 53 | } |
||
| 54 | } |
||
| 55 |
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
Idableprovides a methodequalsIdthat 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.