Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
27 / 27 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
1 / 1 |
| UpdateUserSettingRequest | |
100.00% |
27 / 27 |
|
100.00% |
3 / 3 |
3 | |
100.00% |
1 / 1 |
| authorize | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| rules | |
100.00% |
21 / 21 |
|
100.00% |
1 / 1 |
1 | |||
| messages | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace App\Http\Requests\v1\Setting; |
| 4 | |
| 5 | use Illuminate\Foundation\Http\FormRequest; |
| 6 | |
| 7 | /** |
| 8 | * Request validation for updating user settings. |
| 9 | * |
| 10 | * @property int|null $shortcut_timeout Shortcut activation timeout in milliseconds |
| 11 | * @property array<string>|null $blocked_domains Array of blocked domain URLs |
| 12 | * @property string|null $fly_rewrite FlyRewrite feature status ('enabled' or 'disabled') |
| 13 | * @property array<string>|null $fly_rewrite_blocked_domains Domains where FlyRewrite is disabled |
| 14 | * @property string|null $fly_grammar FlyGrammar feature status ('enabled' or 'disabled') |
| 15 | * @property array<string>|null $fly_grammar_blocked_domains Domains where FlyGrammar is disabled |
| 16 | * @property int|null $words_per_minute User's typing speed in words per minute (min: 1) |
| 17 | * @property int|null $wage_per_hour User's hourly wage for time savings calculations (min: 1) |
| 18 | * @property string|null $typing_style The typing style setting ('word', 'letter', or 'all') |
| 19 | * @property int|null $typing_speed The typing speed value (20-60) |
| 20 | * @property string|null $fly_grammar_default_language Default language code for FlyGrammar (e.g., 'en_US') |
| 21 | * @property int|null $upgrade_coupon_order_displayed Order index of upgrade coupon display |
| 22 | * @property array<string>|null $custom_prompts_order_flyengage Custom ordering of FlyEngage AI prompts |
| 23 | * @property array<string>|null $custom_prompts_order_flypost Custom ordering of FlyPost AI prompts |
| 24 | * @property array<string>|null $custom_fly_write_order Custom ordering of FlyWrite options |
| 25 | * @property string|null $csv_split_separator Single-character separator string for CSV exports (e.g., ",", ";", "|") |
| 26 | */ |
| 27 | class UpdateUserSettingRequest extends FormRequest |
| 28 | { |
| 29 | /** |
| 30 | * Determine if the user is authorized to make this request. |
| 31 | */ |
| 32 | public function authorize(): bool |
| 33 | { |
| 34 | return true; |
| 35 | } |
| 36 | |
| 37 | /** |
| 38 | * Get the validation rules that apply to the request. |
| 39 | * |
| 40 | * @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string> |
| 41 | */ |
| 42 | public function rules(): array |
| 43 | { |
| 44 | return [ |
| 45 | 'shortcut_timeout' => 'sometimes|required|integer', |
| 46 | 'blocked_domains' => 'sometimes|array|min:0', |
| 47 | 'blocked_domains.*' => 'sometimes|string|url|distinct|min:0', |
| 48 | 'fly_rewrite' => 'sometimes|in:enabled,disabled', |
| 49 | 'fly_rewrite_blocked_domains' => 'sometimes|array', |
| 50 | 'fly_rewrite_blocked_domains.*' => 'sometimes|string|min:0', |
| 51 | 'fly_grammar' => 'sometimes|in:enabled,disabled', |
| 52 | 'fly_grammar_blocked_domains' => 'sometimes|array', |
| 53 | 'fly_grammar_blocked_domains.*' => 'sometimes|string|min:0', |
| 54 | 'words_per_minute' => 'sometimes|integer|min:1', |
| 55 | 'wage_per_hour' => 'sometimes|integer|min:1', |
| 56 | 'typing_style' => 'sometimes|string|in:word,letter,all', |
| 57 | 'typing_speed' => 'sometimes|nullable|integer|min:20|max:60', |
| 58 | 'fly_grammar_default_language' => 'sometimes|nullable|string', |
| 59 | 'upgrade_coupon_order_displayed' => 'sometimes|nullable|integer', |
| 60 | 'custom_prompts_order_flyengage' => 'sometimes|nullable|array', |
| 61 | 'custom_prompts_order_flypost' => 'sometimes|nullable|array', |
| 62 | 'custom_fly_write_order' => 'sometimes|nullable|array', |
| 63 | 'csv_split_separator' => 'sometimes|nullable|string|size:1', |
| 64 | ]; |
| 65 | } |
| 66 | |
| 67 | /** |
| 68 | * Get custom error messages for validation rules. |
| 69 | * |
| 70 | * @return array<string, string> |
| 71 | */ |
| 72 | public function messages(): array |
| 73 | { |
| 74 | return [ |
| 75 | 'blocked_domains.*.url' => 'Domain format is invalid.', |
| 76 | 'csv_split_separator.size' => 'The CSV separator must be a single character.', |
| 77 | 'csv_split_separator.string' => 'The CSV separator must be a string character.', |
| 78 | ]; |
| 79 | } |
| 80 | } |