Test Failed
Push — master ( 507036...762659 )
by Julien
21:33
created

ExposeFields::getExposeFields()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
1
<?php
2
3
/**
4
 * This file is part of the Zemit Framework.
5
 *
6
 * (c) Zemit Team <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE.txt
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Zemit\Mvc\Controller\Traits\Query\Fields;
13
14
use Phalcon\Support\Collection;
15
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
55
    {
56
        return $this->exposeFields;
57
    }
58
}
59