| Conditions | 8 |
| Paths | 1 |
| Total Lines | 27 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 42 | public function rules(): array |
||
| 43 | { |
||
| 44 | $user = $this->user($this->route('guard')); |
||
| 45 | |||
| 46 | // Attach attribute rules |
||
| 47 | $user->getEntityAttributes()->each(function ($attribute, $attributeName) use (&$rules) { |
||
| 48 | switch ($attribute->type) { |
||
| 49 | case 'datetime': |
||
| 50 | $type = 'date'; |
||
| 51 | break; |
||
| 52 | case 'text': |
||
| 53 | case 'check': |
||
| 54 | case 'select': |
||
| 55 | case 'varchar': |
||
| 56 | $type = 'string'; |
||
| 57 | break; |
||
| 58 | default: |
||
| 59 | $type = $attribute->type; |
||
| 60 | break; |
||
| 61 | } |
||
| 62 | |||
| 63 | $rule = ($attribute->is_required ? 'required|' : 'nullable|').$type; |
||
| 64 | $rules[$attributeName.($attribute->is_collection ? '.*' : '')] = $rule; |
||
| 65 | }); |
||
| 66 | |||
| 67 | return $rules ?? []; |
||
| 68 | } |
||
| 69 | } |
||
| 70 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.