Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
22 / 22
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
GlobalSettingsResource
100.00% covered (success)
100.00%
22 / 22
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 toArray
100.00% covered (success)
100.00%
22 / 22
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3namespace App\Http\Resources\v2;
4
5use Illuminate\Http\Request;
6use Illuminate\Http\Resources\Json\JsonResource;
7
8/**
9 * Resource for transforming global Setting models for API responses.
10 *
11 * @property string $_id The MongoDB document ID
12 * @property string $user_id The user ID ('app_settings' for global settings)
13 * @property bool $is_global Whether this is a global settings record
14 * @property float $wage_per_hour Average hourly wage for calculations
15 * @property int $words_per_minute Typing speed in words per minute
16 * @property string $typing_style The typing style setting
17 * @property int $typing_speed The typing speed value
18 * @property bool $remove_grammar_on_lose_focus Whether to remove grammar on focus loss
19 * @property string $fly_rewrite FlyRewrite feature status
20 * @property string $fly_grammar FlyGrammar feature status
21 * @property string $fly_grammar_default_language Default language for FlyGrammar
22 * @property array $features Feature flags object
23 * @property array $playlists Playlist configurations
24 * @property array $ignoredInputTypes Input types to ignore
25 * @property array $blackListClasses CSS classes to blacklist
26 * @property array $blackListIds Element IDs to blacklist
27 * @property array $blackListAttributes Attribute name/value pairs to blacklist
28 * @property array $blackListDomainRules Domain-specific blacklist rules
29 * @property \Carbon\Carbon|null $created_at When the setting was created
30 * @property \Carbon\Carbon|null $updated_at When the setting was last updated
31 */
32class GlobalSettingsResource extends JsonResource
33{
34    /**
35     * Transform the resource into an array.
36     *
37     * @return array<string, mixed>
38     */
39    public function toArray(Request $request): array
40    {
41        return [
42            'id' => (string) $this->_id,
43            'user_id' => $this->user_id,
44            'is_global' => $this->is_global,
45
46            // Core settings
47            'wage_per_hour' => $this->wage_per_hour,
48            'words_per_minute' => $this->words_per_minute,
49            'typing_style' => $this->typing_style,
50            'typing_speed' => $this->typing_speed,
51            'remove_grammar_on_lose_focus' => $this->remove_grammar_on_lose_focus,
52
53            // Feature toggles
54            'fly_rewrite' => $this->fly_rewrite,
55            'fly_grammar' => $this->fly_grammar,
56            'fly_grammar_default_language' => $this->fly_grammar_default_language,
57
58            // Feature flags
59            'features' => $this->features,
60
61            // Playlists
62            'playlists' => $this->playlists,
63
64            // Blacklists
65            'ignoredInputTypes' => $this->ignoredInputTypes,
66            'blackListClasses' => $this->blackListClasses,
67            'blackListIds' => $this->blackListIds,
68            'blackListAttributes' => $this->blackListAttributes,
69            'blackListDomainRules' => $this->blackListDomainRules,
70
71            // Timestamps
72            'created_at' => $this->created_at?->timestamp,
73            'updated_at' => $this->updated_at?->timestamp,
74        ];
75    }
76}