| Conditions | 5 |
| Paths | 8 |
| Total Lines | 25 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 83 | public function beforeValidation(Validator $validator) |
||
| 84 | { |
||
| 85 | $rules = []; |
||
| 86 | $identifier = $this->getIdentifier(); |
||
|
|
|||
| 87 | |||
| 88 | if ($this->mimes) |
||
| 89 | { |
||
| 90 | $rules[] = 'mimes:' . $this->mimes; |
||
| 91 | } |
||
| 92 | |||
| 93 | if ($this->max_size) |
||
| 94 | { |
||
| 95 | $rules[] = 'max:' . $this->max_size; |
||
| 96 | } |
||
| 97 | |||
| 98 | if (count($rules) > 0) |
||
| 99 | { |
||
| 100 | $validator->sometimes($this->getIdentifier(), $rules, function (Fluent $input) use ($identifier) |
||
| 101 | { |
||
| 102 | return is_null($input->{$identifier}) ? false : true; |
||
| 103 | }); |
||
| 104 | } |
||
| 105 | |||
| 106 | return $validator; |
||
| 107 | } |
||
| 108 | } |
||
| 109 |
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.