Test Failed
Push — develop ( c753fd...f013d6 )
by nguereza
02:45
created

RoleParam::setDescription()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
rs 10
c 1
b 0
f 0
1
<?php
2
3
/**
4
 * Platine Framework
5
 *
6
 * Platine Framework is a lightweight, high-performance, simple and elegant
7
 * PHP Web framework
8
 *
9
 * This content is released under the MIT License (MIT)
10
 *
11
 * Copyright (c) 2020 Platine Framework
12
 *
13
 * Permission is hereby granted, free of charge, to any person obtaining a copy
14
 * of this software and associated documentation files (the "Software"), to deal
15
 * in the Software without restriction, including without limitation the rights
16
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17
 * copies of the Software, and to permit persons to whom the Software is
18
 * furnished to do so, subject to the following conditions:
19
 *
20
 * The above copyright notice and this permission notice shall be included in all
21
 * copies or substantial portions of the Software.
22
 *
23
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29
 * SOFTWARE.
30
 */
31
32
/**
33
 *  @file RoleParam.php
34
 *
35
 *  The Role form parameter class
36
 *
37
 *  @package    Platine\Framework\Demo\Form\Param
38
 *  @author Platine Developers team
39
 *  @copyright  Copyright (c) 2020
40
 *  @license    http://opensource.org/licenses/MIT  MIT License
41
 *  @link   http://www.iacademy.cf
42
 *  @version 1.0.0
43
 *  @filesource
44
 */
45
46
declare(strict_types=1);
47
48
namespace Platine\Framework\Demo\Form\Param;
49
50
use Platine\Framework\Form\Param\BaseParam;
51
use Platine\Orm\Entity;
52
53
/**
54
 * @class RoleParam
55
 * @package Platine\Framework\Demo\Form\Param
56
 */
57
class RoleParam extends BaseParam
58
{
59
    /**
60
     * The name
61
     * @var string
62
     */
63
    protected string $name = '';
64
65
    /**
66
     * The description
67
     * @var string
68
     */
69
    protected string $description = '';
70
71
    /**
72
     * The selected permissions id
73
     * @var int[]
74
     */
75
    protected array $permissions = [];
76
77
    /**
78
     * {@inheritodc}
79
     */
80
    public function fromEntity(Entity $entity): self
81
    {
82
        $this->name = $entity->name;
83
        $this->description = (string) $entity->description;
84
85
        return $this;
86
    }
87
88
    /**
89
     * Return the name
90
     * @return string
91
     */
92
    public function getName(): string
93
    {
94
        return $this->name;
95
    }
96
97
    /**
98
     * Return the description
99
     * @return string
100
     */
101
    public function getDescription(): string
102
    {
103
        return $this->description;
104
    }
105
106
    /**
107
     * Return the permissions
108
     * @return int[]
109
     */
110
    public function getPermissions(): array
111
    {
112
        return $this->permissions;
113
    }
114
115
    /**
116
     * Set the name
117
     * @param string $name
118
     * @return $this
119
     */
120
    public function setName(string $name): self
121
    {
122
        $this->name = $name;
123
        return $this;
124
    }
125
126
    /**
127
     * Set the description
128
     * @param string $description
129
     * @return $this
130
     */
131
    public function setDescription(string $description): self
132
    {
133
        $this->description = $description;
134
        return $this;
135
    }
136
137
    /**
138
     * Set the permissions
139
     * @param int[] $permissions
140
     * @return $this
141
     */
142
    public function setPermissions(array $permissions): self
143
    {
144
        $this->permissions = $permissions;
145
        return $this;
146
    }
147
}
148