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

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