Passed
Push — 1.0.x ( 8353d5...3a2c37 )
by Julien
21:28
created

MapFields::initializeMapFields()   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 MapFields
17
{
18
    protected ?Collection $mapFields;
19
    
20
    /**
21
     * Initializes the map fields.
22
     *
23
     * This method is responsible for initializing the necessary map fields for the model
24
     *
25
     * @return void
26
     */
27
    public function initializeMapFields(): void
28
    {
29
        $this->setMapFields(null);
30
    }
31
    
32
    /**
33
     * Sets the fields for mapping data.
34
     *
35
     * @param Collection|null $mapFields The array of map fields.
36
     *                                   Pass null to disable the mappings.
37
     */
38
    public function setMapFields(?Collection $mapFields): void
39
    {
40
        $this->mapFields = $mapFields;
41
    }
42
    
43
    /**
44
     * Returns the map fields.
45
     *
46
     * This method retrieves the map fields for the model.
47
     * If map fields have been set, it returns the collection of map fields.
48
     * If no map fields have been set, it returns null.
49
     *
50
     * Note: The map fields are the fields that are mapped during the data assignation (save).
51
     *
52
     * @return Collection|null The collection of map fields or null if no map fields have been set.
53
     */
54
    public function getMapFields(): ?Collection
55
    {
56
        return $this->mapFields;
57
    }
58
}
59