Passed
Pull Request — master (#9)
by nguereza
02:20
created
storage/migrations/20231207_060117_add_products_table.php 3 patches
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -14,35 +14,35 @@
 block discarded – undo
14 14
         //Action when migrate up
15 15
         $this->create('products', function (CreateTable $table) {
16 16
             $table->integer('id')
17
-                  ->autoincrement()
18
-                 ->primary();
17
+                    ->autoincrement()
18
+                    ->primary();
19 19
             
20 20
             $table->string('name')
21
-                 ->description('The product name')
22
-                 ->notNull();
21
+                    ->description('The product name')
22
+                    ->notNull();
23 23
             
24 24
             $table->string('description')
25
-                 ->description('The product description');
25
+                    ->description('The product description');
26 26
             
27 27
             $table->float('price')
28
-                   ->defaultValue(0)
29
-                   ->description('The product price')
30
-                   ->notNull();
28
+                    ->defaultValue(0)
29
+                    ->description('The product price')
30
+                    ->notNull();
31 31
             
32 32
             $table->float('quantity')
33
-                   ->defaultValue(0)
34
-                   ->description('The product quantity')
35
-                   ->notNull();
33
+                    ->defaultValue(0)
34
+                    ->description('The product quantity')
35
+                    ->notNull();
36 36
             
37 37
             $table->integer('product_category_id')
38
-                 ->description('Product category')
39
-                  ->notNull();
38
+                    ->description('Product category')
39
+                    ->notNull();
40 40
             
41 41
             $table->timestamps();
42 42
             
43 43
             $table->foreign('product_category_id')
44
-                  ->references('product_categories', 'id')
45
-                  ->onDelete('NO ACTION');
44
+                    ->references('product_categories', 'id')
45
+                    ->onDelete('NO ACTION');
46 46
 
47 47
             $table->engine('INNODB');
48 48
         });
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@
 block discarded – undo
12 12
     public function up(): void
13 13
     {
14 14
         //Action when migrate up
15
-        $this->create('products', function (CreateTable $table) {
15
+        $this->create('products', function(CreateTable $table) {
16 16
             $table->integer('id')
17 17
                   ->autoincrement()
18 18
                  ->primary();
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -6,8 +6,7 @@
 block discarded – undo
6 6
 use Platine\Database\Schema\CreateTable;
7 7
 use Platine\Framework\Migration\AbstractMigration;
8 8
 
9
-class AddProductsTable20231207060117 extends AbstractMigration
10
-{
9
+class AddProductsTable20231207060117 extends AbstractMigration {
11 10
 
12 11
     public function up(): void
13 12
     {
Please login to merge, or discard this patch.
app/Provider/ProductServiceProvider.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@
 block discarded – undo
35 35
     */
36 36
     public function addRoutes(Router $router): void
37 37
     {
38
-        $router->group('/product', function (Router $router) {
38
+        $router->group('/product', function(Router $router) {
39 39
             $router->resource('', ProductAction::class, 'product');
40 40
             $router->resource('/category', CategoryAction::class, 'product_category');
41 41
         });
Please login to merge, or discard this patch.
app/Model/Repository/ProductRepository.php 2 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -16,9 +16,9 @@
 block discarded – undo
16 16
 class ProductRepository extends Repository
17 17
 {
18 18
     /**
19
-    * Create new instance
20
-    * @param EntityManager<Product> $manager
21
-    */
19
+     * Create new instance
20
+     * @param EntityManager<Product> $manager
21
+     */
22 22
     public function __construct(EntityManager $manager)
23 23
     {
24 24
         parent::__construct($manager, Product::class);
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -13,14 +13,12 @@
 block discarded – undo
13 13
 * @package Platine\App\Model\Repository
14 14
 * @extends Repository<Product>
15 15
 */
16
-class ProductRepository extends Repository
17
-{
16
+class ProductRepository extends Repository {
18 17
     /**
19 18
     * Create new instance
20 19
     * @param EntityManager<Product> $manager
21 20
     */
22
-    public function __construct(EntityManager $manager)
23
-    {
21
+    public function __construct(EntityManager $manager) {
24 22
         parent::__construct($manager, Product::class);
25 23
     }
26 24
 }
Please login to merge, or discard this patch.
app/Model/Entity/Product.php 3 patches
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -16,21 +16,21 @@
 block discarded – undo
16 16
 class Product extends Entity
17 17
 {
18 18
     /**
19
-    * @param EntityMapperInterface<Product> $mapper
20
-    * @return void
21
-    */
19
+     * @param EntityMapperInterface<Product> $mapper
20
+     * @return void
21
+     */
22 22
     public static function mapEntity(EntityMapperInterface $mapper): void
23 23
     {
24
-         $mapper->useTimestamp();
25
-         $mapper->casts([
24
+            $mapper->useTimestamp();
25
+            $mapper->casts([
26 26
             'created_at' => 'date',
27 27
             'updated_at' => '?date',
28
-         ]);
28
+            ]);
29 29
 
30
-         $mapper->relation('category')->belongsTo(ProductCategory::class);
30
+            $mapper->relation('category')->belongsTo(ProductCategory::class);
31 31
 
32
-         $mapper->filter('category', function (Query $q, $value) {
33
-             $q->where('product_category_id')->is($value);
34
-         });
32
+            $mapper->filter('category', function (Query $q, $value) {
33
+                $q->where('product_category_id')->is($value);
34
+            });
35 35
     }
36 36
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@
 block discarded – undo
29 29
 
30 30
          $mapper->relation('category')->belongsTo(ProductCategory::class);
31 31
 
32
-         $mapper->filter('category', function (Query $q, $value) {
32
+         $mapper->filter('category', function(Query $q, $value) {
33 33
              $q->where('product_category_id')->is($value);
34 34
          });
35 35
     }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -13,8 +13,7 @@
 block discarded – undo
13 13
 * @package Platine\App\Model\Entity
14 14
 * @extends Entity<Product>
15 15
 */
16
-class Product extends Entity
17
-{
16
+class Product extends Entity {
18 17
     /**
19 18
     * @param EntityMapperInterface<Product> $mapper
20 19
     * @return void
Please login to merge, or discard this patch.
app/Http/Action/Product/ProductAction.php 2 patches
Indentation   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -29,66 +29,66 @@  discard block
 block discarded – undo
29 29
 class ProductAction
30 30
 {
31 31
     /**
32
-    * The Lang instance
33
-    * @var Lang
34
-    */
32
+     * The Lang instance
33
+     * @var Lang
34
+     */
35 35
     protected Lang $lang;
36 36
 
37 37
     /**
38
-    * The Pagination instance
39
-    * @var Pagination
40
-    */
38
+     * The Pagination instance
39
+     * @var Pagination
40
+     */
41 41
     protected Pagination $pagination;
42 42
 
43 43
     /**
44
-    * The Template instance
45
-    * @var Template
46
-    */
44
+     * The Template instance
45
+     * @var Template
46
+     */
47 47
     protected Template $template;
48 48
 
49 49
     /**
50
-    * The Flash instance
51
-    * @var Flash
52
-    */
50
+     * The Flash instance
51
+     * @var Flash
52
+     */
53 53
     protected Flash $flash;
54 54
 
55 55
     /**
56
-    * The RouteHelper instance
57
-    * @var RouteHelper
58
-    */
56
+     * The RouteHelper instance
57
+     * @var RouteHelper
58
+     */
59 59
     protected RouteHelper $routeHelper;
60 60
 
61 61
     /**
62
-    * The LoggerInterface instance
63
-    * @var LoggerInterface
64
-    */
62
+     * The LoggerInterface instance
63
+     * @var LoggerInterface
64
+     */
65 65
     protected LoggerInterface $logger;
66 66
 
67 67
     /**
68
-    * The ProductCategoryRepository instance
69
-    * @var ProductCategoryRepository
70
-    */
68
+     * The ProductCategoryRepository instance
69
+     * @var ProductCategoryRepository
70
+     */
71 71
     protected ProductCategoryRepository $productCategoryRepository;
72 72
 
73 73
     /**
74
-    * The ProductRepository instance
75
-    * @var ProductRepository
76
-    */
74
+     * The ProductRepository instance
75
+     * @var ProductRepository
76
+     */
77 77
     protected ProductRepository $productRepository;
78 78
 
79 79
 
80 80
 
81 81
     /**
82
-    * Create new instance
83
-    * @param Lang $lang
84
-    * @param Pagination $pagination
85
-    * @param Template $template
86
-    * @param Flash $flash
87
-    * @param RouteHelper $routeHelper
88
-    * @param LoggerInterface $logger
89
-    * @param ProductCategoryRepository $productCategoryRepository
90
-    * @param ProductRepository $productRepository
91
-    */
82
+     * Create new instance
83
+     * @param Lang $lang
84
+     * @param Pagination $pagination
85
+     * @param Template $template
86
+     * @param Flash $flash
87
+     * @param RouteHelper $routeHelper
88
+     * @param LoggerInterface $logger
89
+     * @param ProductCategoryRepository $productCategoryRepository
90
+     * @param ProductRepository $productRepository
91
+     */
92 92
     public function __construct(
93 93
         Lang $lang,
94 94
         Pagination $pagination,
@@ -110,10 +110,10 @@  discard block
 block discarded – undo
110 110
     }
111 111
 
112 112
     /**
113
-    * List all entities
114
-    * @param ServerRequestInterface $request
115
-    * @return ResponseInterface
116
-    */
113
+     * List all entities
114
+     * @param ServerRequestInterface $request
115
+     * @return ResponseInterface
116
+     */
117 117
     public function index(ServerRequestInterface $request): ResponseInterface
118 118
     {
119 119
         $context = [];
@@ -132,8 +132,8 @@  discard block
 block discarded – undo
132 132
         }
133 133
 
134 134
         $totalItems = $this->productRepository->query()
135
-                                              ->filter($filters)
136
-                                               ->count('id');
135
+                                                ->filter($filters)
136
+                                                ->count('id');
137 137
 
138 138
         $currentPage = (int) $param->get('page', 1);
139 139
 
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
                                             ->all();
153 153
 
154 154
         $categories = $this->productCategoryRepository->orderBy('name')
155
-                                                      ->all();
155
+                                                        ->all();
156 156
 
157 157
         $context['categories'] = $categories;
158 158
 
@@ -169,10 +169,10 @@  discard block
 block discarded – undo
169 169
     }
170 170
 
171 171
     /**
172
-    * List entity detail
173
-    * @param ServerRequestInterface $request
174
-    * @return ResponseInterface
175
-    */
172
+     * List entity detail
173
+     * @param ServerRequestInterface $request
174
+     * @return ResponseInterface
175
+     */
176 176
     public function detail(ServerRequestInterface $request): ResponseInterface
177 177
     {
178 178
         $context = [];
@@ -198,10 +198,10 @@  discard block
 block discarded – undo
198 198
     }
199 199
 
200 200
     /**
201
-    * Create new entity
202
-    * @param ServerRequestInterface $request
203
-    * @return ResponseInterface
204
-    */
201
+     * Create new entity
202
+     * @param ServerRequestInterface $request
203
+     * @return ResponseInterface
204
+     */
205 205
     public function create(ServerRequestInterface $request): ResponseInterface
206 206
     {
207 207
         $context = [];
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
         $context['param'] = $formParam;
212 212
 
213 213
         $categories = $this->productCategoryRepository->orderBy('name')
214
-                                                      ->all();
214
+                                                        ->all();
215 215
 
216 216
         $context['categories'] = $categories;
217 217
 
@@ -235,8 +235,8 @@  discard block
 block discarded – undo
235 235
         }
236 236
 
237 237
         $entityExist = $this->productRepository->findBy([
238
-                                               'name' => $formParam->getName(),
239
-                                           ]);
238
+                                                'name' => $formParam->getName(),
239
+                                            ]);
240 240
 
241 241
         if ($entityExist !== null) {
242 242
             $this->flash->setError($this->lang->tr('This record already exist'));
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
 
251 251
         /** @var Product $product */
252 252
         $product = $this->productRepository->create([
253
-           'name' => $formParam->getName(),
253
+            'name' => $formParam->getName(),
254 254
         'description' => $formParam->getDescription(),
255 255
         'price' => $formParam->getPrice(),
256 256
         'quantity' => $formParam->getQuantity(),
@@ -279,10 +279,10 @@  discard block
 block discarded – undo
279 279
     }
280 280
 
281 281
     /**
282
-    * Update existing entity
283
-    * @param ServerRequestInterface $request
284
-    * @return ResponseInterface
285
-    */
282
+     * Update existing entity
283
+     * @param ServerRequestInterface $request
284
+     * @return ResponseInterface
285
+     */
286 286
     public function update(ServerRequestInterface $request): ResponseInterface
287 287
     {
288 288
         $context = [];
@@ -304,7 +304,7 @@  discard block
 block discarded – undo
304 304
         $context['param'] = (new ProductParam())->fromEntity($product);
305 305
 
306 306
         $categories = $this->productCategoryRepository->orderBy('name')
307
-                                                      ->all();
307
+                                                        ->all();
308 308
 
309 309
         $context['categories'] = $categories;
310 310
 
@@ -330,8 +330,8 @@  discard block
 block discarded – undo
330 330
         }
331 331
 
332 332
         $entityExist = $this->productRepository->findBy([
333
-                                               'name' => $formParam->getName(),
334
-                                           ]);
333
+                                                'name' => $formParam->getName(),
334
+                                            ]);
335 335
 
336 336
         if ($entityExist !== null && $entityExist->id !== $id) {
337 337
             $this->flash->setError($this->lang->tr('This record already exist'));
@@ -371,10 +371,10 @@  discard block
 block discarded – undo
371 371
     }
372 372
 
373 373
     /**
374
-    * Delete the entity
375
-    * @param ServerRequestInterface $request
376
-    * @return ResponseInterface
377
-    */
374
+     * Delete the entity
375
+     * @param ServerRequestInterface $request
376
+     * @return ResponseInterface
377
+     */
378 378
     public function delete(ServerRequestInterface $request): ResponseInterface
379 379
     {
380 380
         $id = (int) $request->getAttribute('id');
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -26,8 +26,7 @@
 block discarded – undo
26 26
 * @class ProductAction
27 27
 * @package Platine\App\Http\Action\Product
28 28
 */
29
-class ProductAction
30
-{
29
+class ProductAction {
31 30
     /**
32 31
     * The Lang instance
33 32
     * @var Lang
Please login to merge, or discard this patch.
app/Param/ProductParam.php 2 patches
Indentation   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -15,40 +15,40 @@  discard block
 block discarded – undo
15 15
 class ProductParam extends BaseParam
16 16
 {
17 17
     /**
18
-    * The name field
19
-    * @var string
20
-    */
18
+     * The name field
19
+     * @var string
20
+     */
21 21
     protected string $name;
22 22
 
23 23
     /**
24
-    * The description field
25
-    * @var string|null
26
-    */
24
+     * The description field
25
+     * @var string|null
26
+     */
27 27
     protected ?string $description = null;
28 28
 
29 29
     /**
30
-    * The price field
31
-    * @var float
32
-    */
30
+     * The price field
31
+     * @var float
32
+     */
33 33
     protected float $price = 0;
34 34
 
35 35
     /**
36
-    * The quantity field
37
-    * @var float
38
-    */
36
+     * The quantity field
37
+     * @var float
38
+     */
39 39
     protected float $quantity = 0;
40 40
 
41 41
     /**
42
-    * The category field
43
-    * @var int
44
-    */
42
+     * The category field
43
+     * @var int
44
+     */
45 45
     protected int $category;
46 46
 
47 47
 
48 48
     /**
49
-    * @param TEntity $entity
50
-    * @return $this
51
-    */
49
+     * @param TEntity $entity
50
+     * @return $this
51
+     */
52 52
     public function fromEntity(Entity $entity): self
53 53
     {
54 54
         $this->name = $entity->name;
@@ -61,45 +61,45 @@  discard block
 block discarded – undo
61 61
     }
62 62
 
63 63
     /**
64
-    * Return the name value
65
-    * @return string
66
-    */
64
+     * Return the name value
65
+     * @return string
66
+     */
67 67
     public function getName(): string
68 68
     {
69 69
         return $this->name;
70 70
     }
71 71
 
72
-   /**
73
-    * Return the description value
74
-    * @return string|null
75
-    */
72
+    /**
73
+     * Return the description value
74
+     * @return string|null
75
+     */
76 76
     public function getDescription(): ?string
77 77
     {
78 78
         return $this->description;
79 79
     }
80 80
 
81
-   /**
82
-    * Return the price value
83
-    * @return float
84
-    */
81
+    /**
82
+     * Return the price value
83
+     * @return float
84
+     */
85 85
     public function getPrice(): float
86 86
     {
87 87
         return $this->price;
88 88
     }
89 89
 
90
-   /**
91
-    * Return the quantity value
92
-    * @return float
93
-    */
90
+    /**
91
+     * Return the quantity value
92
+     * @return float
93
+     */
94 94
     public function getQuantity(): float
95 95
     {
96 96
         return $this->quantity;
97 97
     }
98 98
 
99
-   /**
100
-    * Return the category value
101
-    * @return int
102
-    */
99
+    /**
100
+     * Return the category value
101
+     * @return int
102
+     */
103 103
     public function getCategory(): int
104 104
     {
105 105
         return $this->category;
@@ -107,10 +107,10 @@  discard block
 block discarded – undo
107 107
 
108 108
 
109 109
     /**
110
-    * Set the name value
111
-    * @param string $name
112
-    * @return $this
113
-    */
110
+     * Set the name value
111
+     * @param string $name
112
+     * @return $this
113
+     */
114 114
     public function setName(string $name): self
115 115
     {
116 116
         $this->name = $name;
@@ -118,11 +118,11 @@  discard block
 block discarded – undo
118 118
         return $this;
119 119
     }
120 120
 
121
-   /**
122
-    * Set the description value
123
-    * @param string|null $description
124
-    * @return $this
125
-    */
121
+    /**
122
+     * Set the description value
123
+     * @param string|null $description
124
+     * @return $this
125
+     */
126 126
     public function setDescription(?string $description): self
127 127
     {
128 128
         $this->description = $description;
@@ -130,11 +130,11 @@  discard block
 block discarded – undo
130 130
         return $this;
131 131
     }
132 132
 
133
-   /**
134
-    * Set the price value
135
-    * @param float $price
136
-    * @return $this
137
-    */
133
+    /**
134
+     * Set the price value
135
+     * @param float $price
136
+     * @return $this
137
+     */
138 138
     public function setPrice(float $price): self
139 139
     {
140 140
         $this->price = $price;
@@ -142,11 +142,11 @@  discard block
 block discarded – undo
142 142
         return $this;
143 143
     }
144 144
 
145
-   /**
146
-    * Set the quantity value
147
-    * @param float $quantity
148
-    * @return $this
149
-    */
145
+    /**
146
+     * Set the quantity value
147
+     * @param float $quantity
148
+     * @return $this
149
+     */
150 150
     public function setQuantity(float $quantity): self
151 151
     {
152 152
         $this->quantity = $quantity;
@@ -154,11 +154,11 @@  discard block
 block discarded – undo
154 154
         return $this;
155 155
     }
156 156
 
157
-   /**
158
-    * Set the category value
159
-    * @param int $category
160
-    * @return $this
161
-    */
157
+    /**
158
+     * Set the category value
159
+     * @param int $category
160
+     * @return $this
161
+     */
162 162
     public function setCategory(int $category): self
163 163
     {
164 164
         $this->category = $category;
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -12,8 +12,7 @@
 block discarded – undo
12 12
 * @package Platine\App\Param
13 13
 * @template TEntity as Entity
14 14
 */
15
-class ProductParam extends BaseParam
16
-{
15
+class ProductParam extends BaseParam {
17 16
     /**
18 17
     * The name field
19 18
     * @var string
Please login to merge, or discard this patch.
app/Validator/ProductValidator.php 2 patches
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -22,16 +22,16 @@  discard block
 block discarded – undo
22 22
 class ProductValidator extends AbstractValidator
23 23
 {
24 24
     /**
25
-    * The parameter instance
26
-    * @var ProductParam<TEntity>
27
-    */
25
+     * The parameter instance
26
+     * @var ProductParam<TEntity>
27
+     */
28 28
     protected ProductParam $param;
29 29
 
30 30
     /**
31
-    * Create new instance
32
-    * @param ProductParam<TEntity> $param
33
-    * @param Lang $lang
34
-    */
31
+     * Create new instance
32
+     * @param ProductParam<TEntity> $param
33
+     * @param Lang $lang
34
+     */
35 35
     public function __construct(ProductParam $param, Lang $lang)
36 36
     {
37 37
         parent::__construct($lang);
@@ -39,8 +39,8 @@  discard block
 block discarded – undo
39 39
     }
40 40
 
41 41
     /**
42
-    * {@inheritdoc}
43
-    */
42
+     * {@inheritdoc}
43
+     */
44 44
     public function setValidationData(): void
45 45
     {
46 46
         $this->addData('name', $this->param->getName());
@@ -51,8 +51,8 @@  discard block
 block discarded – undo
51 51
     }
52 52
 
53 53
     /**
54
-    * {@inheritdoc}
55
-    */
54
+     * {@inheritdoc}
55
+     */
56 56
     public function setValidationRules(): void
57 57
     {
58 58
         $this->addRules('name', [
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -19,8 +19,7 @@  discard block
 block discarded – undo
19 19
 * @package Platine\App\Validator
20 20
 * @template TEntity as \Platine\Orm\Entity
21 21
 */
22
-class ProductValidator extends AbstractValidator
23
-{
22
+class ProductValidator extends AbstractValidator {
24 23
     /**
25 24
     * The parameter instance
26 25
     * @var ProductParam<TEntity>
@@ -32,8 +31,7 @@  discard block
 block discarded – undo
32 31
     * @param ProductParam<TEntity> $param
33 32
     * @param Lang $lang
34 33
     */
35
-    public function __construct(ProductParam $param, Lang $lang)
36
-    {
34
+    public function __construct(ProductParam $param, Lang $lang) {
37 35
         parent::__construct($lang);
38 36
         $this->param = $param;
39 37
     }
Please login to merge, or discard this patch.