Passed
Pull Request — master (#9)
by nguereza
02:20
created

ProductParam   A

Complexity

Total Complexity 11

Size/Duplication

Total Lines 152
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 27
c 1
b 0
f 0
dl 0
loc 152
rs 10
wmc 11

11 Methods

Rating   Name   Duplication   Size   Complexity  
A getCategory() 0 3 1
A setQuantity() 0 5 1
A getDescription() 0 3 1
A setPrice() 0 5 1
A getPrice() 0 3 1
A setDescription() 0 5 1
A getQuantity() 0 3 1
A getName() 0 3 1
A fromEntity() 0 9 1
A setCategory() 0 5 1
A setName() 0 5 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Platine\App\Param;
6
7
use Platine\Framework\Form\Param\BaseParam;
8
use Platine\Orm\Entity;
9
10
/**
11
* @class ProductParam
12
* @package Platine\App\Param
13
* @template TEntity as Entity
14
*/
15
class ProductParam extends BaseParam
16
{
17
    /**
18
    * The name field
19
    * @var string
20
    */
21
    protected string $name;
22
23
    /**
24
    * The description field
25
    * @var string|null
26
    */
27
    protected ?string $description = null;
28
29
    /**
30
    * The price field
31
    * @var float
32
    */
33
    protected float $price = 0;
34
35
    /**
36
    * The quantity field
37
    * @var float
38
    */
39
    protected float $quantity = 0;
40
41
    /**
42
    * The category field
43
    * @var int
44
    */
45
    protected int $category;
46
47
48
    /**
49
    * @param TEntity $entity
0 ignored issues
show
Bug introduced by
The type Platine\App\Param\TEntity was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
50
    * @return $this
51
    */
52
    public function fromEntity(Entity $entity): self
53
    {
54
        $this->name = $entity->name;
55
        $this->description = $entity->description;
56
        $this->price = $entity->price;
57
        $this->quantity = $entity->quantity;
58
        $this->category = $entity->product_category_id;
59
60
        return $this;
61
    }
62
63
    /**
64
    * Return the name value
65
    * @return string
66
    */
67
    public function getName(): string
68
    {
69
        return $this->name;
70
    }
71
72
   /**
73
    * Return the description value
74
    * @return string|null
75
    */
76
    public function getDescription(): ?string
77
    {
78
        return $this->description;
79
    }
80
81
   /**
82
    * Return the price value
83
    * @return float
84
    */
85
    public function getPrice(): float
86
    {
87
        return $this->price;
88
    }
89
90
   /**
91
    * Return the quantity value
92
    * @return float
93
    */
94
    public function getQuantity(): float
95
    {
96
        return $this->quantity;
97
    }
98
99
   /**
100
    * Return the category value
101
    * @return int
102
    */
103
    public function getCategory(): int
104
    {
105
        return $this->category;
106
    }
107
108
109
    /**
110
    * Set the name value
111
    * @param string $name
112
    * @return $this
113
    */
114
    public function setName(string $name): self
115
    {
116
        $this->name = $name;
117
118
        return $this;
119
    }
120
121
   /**
122
    * Set the description value
123
    * @param string|null $description
124
    * @return $this
125
    */
126
    public function setDescription(?string $description): self
127
    {
128
        $this->description = $description;
129
130
        return $this;
131
    }
132
133
   /**
134
    * Set the price value
135
    * @param float $price
136
    * @return $this
137
    */
138
    public function setPrice(float $price): self
139
    {
140
        $this->price = $price;
141
142
        return $this;
143
    }
144
145
   /**
146
    * Set the quantity value
147
    * @param float $quantity
148
    * @return $this
149
    */
150
    public function setQuantity(float $quantity): self
151
    {
152
        $this->quantity = $quantity;
153
154
        return $this;
155
    }
156
157
   /**
158
    * Set the category value
159
    * @param int $category
160
    * @return $this
161
    */
162
    public function setCategory(int $category): self
163
    {
164
        $this->category = $category;
165
166
        return $this;
167
    }
168
}
169