Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
10 / 10
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
PlanComparisonResource
100.00% covered (success)
100.00%
10 / 10
100.00% covered (success)
100.00%
2 / 2
2
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 toArray
100.00% covered (success)
100.00%
9 / 9
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3namespace App\Http\Resources\v2;
4
5use App\DTO\PlanComparisonDTO;
6use Illuminate\Http\Request;
7use Illuminate\Http\Resources\Json\JsonResource;
8
9/**
10 * Resource for transforming PlanComparisonDTO for API responses.
11 *
12 * This resource formats the plan comparison data for frontend consumption,
13 * including the comparison matrix, differences, and summary statistics.
14 *
15 * @property PlanComparisonDTO $resource
16 */
17class PlanComparisonResource extends JsonResource
18{
19    /**
20     * Create a new resource instance.
21     */
22    public function __construct(PlanComparisonDTO $resource)
23    {
24        parent::__construct($resource);
25    }
26
27    /**
28     * Transform the resource into an array.
29     *
30     * @return array<string, mixed>
31     */
32    public function toArray(Request $request): array
33    {
34        return [
35            'plans' => $this->resource->plans,
36            'features' => $this->resource->features,
37            'comparison_matrix' => $this->resource->comparisonMatrix,
38            'differences' => $this->resource->differences,
39            'common_features' => $this->resource->commonFeatures,
40            'hubspot_status' => $this->resource->hubspotStatus,
41            'summary' => $this->resource->summary,
42        ];
43    }
44}