Total Complexity | 3 |
Total Lines | 41 |
Duplicated Lines | 0 % |
Coverage | 0% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
16 | trait ExposeFields |
||
17 | { |
||
18 | protected ?Collection $exposeFields; |
||
19 | |||
20 | /** |
||
21 | * Initializes the expose fields. |
||
22 | * |
||
23 | * This method is responsible for initializing the necessary expose fields for the model |
||
24 | * |
||
25 | * @return void |
||
26 | */ |
||
27 | public function initializeExposeFields(): void |
||
28 | { |
||
29 | $this->setExposeFields(null); |
||
30 | } |
||
31 | |||
32 | /** |
||
33 | * Sets the fields for exposing data. |
||
34 | * |
||
35 | * @param Collection|null $exposeFields The array of expose fields. |
||
36 | * Pass null to allow exposing all fields. |
||
37 | */ |
||
38 | public function setExposeFields(?Collection $exposeFields): void |
||
39 | { |
||
40 | $this->exposeFields = $exposeFields; |
||
41 | } |
||
42 | |||
43 | /** |
||
44 | * Returns the expose fields. |
||
45 | * |
||
46 | * This method retrieves the expose fields for the model. |
||
47 | * If expose fields have been set, it returns the collection of expose fields. |
||
48 | * If no expose fields have been set, it returns null. |
||
49 | * |
||
50 | * Note: The expose fields are the fields that are exposed with the response. |
||
51 | * |
||
52 | * @return Collection|null The collection of expose fields or null if no expose fields have been set. |
||
53 | */ |
||
54 | public function getExposeFields(): ?Collection |
||
57 | } |
||
58 | } |
||
59 |