Completed
Push — support-coverage ( 9b57a3...b5dae6 )
by Kentaro
41:38
created

ProductController::addFavorite()   B

Complexity

Conditions 2
Paths 2

Size

Total Lines 43
Code Lines 23

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 22
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 23
nc 2
nop 2
dl 0
loc 43
ccs 22
cts 22
cp 1
crap 2
rs 8.8571
c 0
b 0
f 0
1
<?php
2
/*
3
 * This file is part of EC-CUBE
4
 *
5
 * Copyright(c) 2000-2015 LOCKON CO.,LTD. All Rights Reserved.
6
 *
7
 * http://www.lockon.co.jp/
8
 *
9
 * This program is free software; you can redistribute it and/or
10
 * modify it under the terms of the GNU General Public License
11
 * as published by the Free Software Foundation; either version 2
12
 * of the License, or (at your option) any later version.
13
 *
14
 * This program is distributed in the hope that it will be useful,
15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 * GNU General Public License for more details.
18
 *
19
 * You should have received a copy of the GNU General Public License
20
 * along with this program; if not, write to the Free Software
21
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
22
 */
23
24
namespace Eccube\Controller;
25
26
use Eccube\Entity\BaseInfo;
27
use Eccube\Entity\Master\ProductStatus;
28
use Eccube\Entity\Product;
29
use Eccube\Event\EccubeEvents;
30
use Eccube\Event\EventArgs;
31
use Eccube\Exception\CartException;
32
use Eccube\Form\Type\AddCartType;
33
use Eccube\Form\Type\Master\ProductListMaxType;
34
use Eccube\Form\Type\Master\ProductListOrderByType;
35
use Eccube\Form\Type\SearchProductType;
36
use Eccube\Repository\CustomerFavoriteProductRepository;
37
use Eccube\Repository\ProductRepository;
38
use Eccube\Service\CartService;
39
use Eccube\Service\PurchaseFlow\PurchaseContext;
40
use Eccube\Service\PurchaseFlow\PurchaseFlow;
41
use Knp\Component\Pager\Paginator;
42
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
43
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
44
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
45
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
46
use Symfony\Component\HttpFoundation\JsonResponse;
47
use Symfony\Component\HttpFoundation\Request;
48
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
49
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
50
51
/**
52
 * @Route(service=ProductController::class)
53
 */
54
class ProductController extends AbstractController
55
{
56
    /**
57
     * @var PurchaseFlow
58
     */
59
    protected $purchaseFlow;
60
61
    /**
62
     * @var CustomerFavoriteProductRepository
63
     */
64
    protected $customerFavoriteProductRepository;
65
66
    /**
67
     * @var CartService
68
     */
69
    protected $cartService;
70
71
    /**
72
     * @var ProductRepository
73
     */
74
    protected $productRepository;
75
76
    /**
77
     * @var BaseInfo
78
     */
79
    protected $BaseInfo;
80
81
    /**
82
     * @var AuthenticationUtils
83
     */
84
    protected $helper;
85
86
    private $title = '';
87
88
    /**
89
     * ProductController constructor.
90
     *
91
     * @param PurchaseFlow $cartPurchaseFlow
0 ignored issues
show
introduced by
Expected 22 spaces after parameter type; 1 found
Loading history...
92
     * @param CustomerFavoriteProductRepository $customerFavoriteProductRepository
93
     * @param CartService $cartService
0 ignored issues
show
introduced by
Expected 23 spaces after parameter type; 1 found
Loading history...
94
     * @param ProductRepository $productRepository
0 ignored issues
show
introduced by
Expected 17 spaces after parameter type; 1 found
Loading history...
95
     * @param BaseInfo $BaseInfo
0 ignored issues
show
introduced by
Expected 26 spaces after parameter type; 1 found
Loading history...
96
     * @param AuthenticationUtils $helper
0 ignored issues
show
introduced by
Expected 15 spaces after parameter type; 1 found
Loading history...
97
     */
98 45
    public function __construct(
99
        PurchaseFlow $cartPurchaseFlow,
100
        CustomerFavoriteProductRepository $customerFavoriteProductRepository,
101
        CartService $cartService,
102
        ProductRepository $productRepository,
103
        BaseInfo $BaseInfo,
104
        AuthenticationUtils $helper
105
    ) {
106 45
        $this->purchaseFlow = $cartPurchaseFlow;
107 45
        $this->customerFavoriteProductRepository = $customerFavoriteProductRepository;
108 45
        $this->cartService = $cartService;
109 45
        $this->productRepository = $productRepository;
110 45
        $this->BaseInfo = $BaseInfo;
111 45
        $this->helper = $helper;
112
    }
113
114
    /**
0 ignored issues
show
introduced by
Doc comment for parameter "$request" missing
Loading history...
introduced by
Doc comment for parameter "$paginator" missing
Loading history...
115
     * 商品一覧画面.
116
     *
117
     * @Route("/products/list", name="product_list")
118
     * @Template("Product/list.twig")
119
     */
0 ignored issues
show
introduced by
Missing @return tag in function comment
Loading history...
120 3
    public function index(Request $request, Paginator $paginator)
121
    {
122
        // Doctrine SQLFilter
123
        // if ($this->BaseInfo->isOptionNostockHidden()) {
0 ignored issues
show
Unused Code Comprehensibility introduced by
65% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
124
        //     $this->entityManager->getFilters()->enable('option_nostock_hidden');
0 ignored issues
show
Unused Code Comprehensibility introduced by
72% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
125
        // }
126
127
        // handleRequestは空のqueryの場合は無視するため
128 3
        if ($request->getMethod() === 'GET') {
129 3
            $request->query->set('pageno', $request->query->get('pageno', ''));
130
        }
131
132
        // searchForm
133
        /* @var $builder \Symfony\Component\Form\FormBuilderInterface */
134 3
        $builder = $this->formFactory->createNamedBuilder('', SearchProductType::class);
135 3
        $builder->setAttribute('freeze', true);
136 3
        $builder->setAttribute('freeze_display_text', false);
137 3
        if ($request->getMethod() === 'GET') {
138 3
            $builder->setMethod('GET');
139
        }
140
141 3
        $event = new EventArgs(
142
            [
143 3
                'builder' => $builder,
144
            ],
145 3
            $request
146
        );
147 3
        $this->eventDispatcher->dispatch(EccubeEvents::FRONT_PRODUCT_INDEX_INITIALIZE, $event);
148
149
        /* @var $searchForm \Symfony\Component\Form\FormInterface */
150 3
        $searchForm = $builder->getForm();
151
152 3
        $searchForm->handleRequest($request);
153
154
        // paginator
155 3
        $searchData = $searchForm->getData();
156 3
        $qb = $this->productRepository->getQueryBuilderBySearchData($searchData);
157
158 3
        $event = new EventArgs(
159
            [
160 3
                'searchData' => $searchData,
161 3
                'qb' => $qb,
162
            ],
163 3
            $request
164
        );
165 3
        $this->eventDispatcher->dispatch(EccubeEvents::FRONT_PRODUCT_INDEX_SEARCH, $event);
166 3
        $searchData = $event->getArgument('searchData');
167
168 3
        $pagination = $paginator->paginate(
169 3
            $qb,
170 3
            !empty($searchData['pageno']) ? $searchData['pageno'] : 1,
171 3
            $searchData['disp_number']->getId()
172
        );
173
174
        // addCart form
175 3
        $forms = [];
176 3
        foreach ($pagination as $Product) {
0 ignored issues
show
Bug introduced by
The expression $pagination of type object<Knp\Component\Pag...on\PaginationInterface> is not traversable.
Loading history...
177
            /* @var $builder \Symfony\Component\Form\FormBuilderInterface */
178 3
            $builder = $this->formFactory->createNamedBuilder(
179 3
                '',
180 3
                AddCartType::class,
181 3
                null,
182
                [
183 3
                    'product' => $Product,
184
                    'allow_extra_fields' => true,
185
                ]
186
            );
187 3
            $addCartForm = $builder->getForm();
188
189 3
            if ($request->getMethod() === 'POST' && (string) $Product->getId() === $request->get('product_id')) {
190
                $addCartForm->handleRequest($request);
191
192
                if ($addCartForm->isValid()) {
193
                    $addCartData = $addCartForm->getData();
194
195
                    try {
196
                        $this->cartService->addProduct(
0 ignored issues
show
Bug introduced by
The method save cannot be called on $this->cartService->addP...ddCartData['quantity']) (of type boolean).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
197
                            $addCartData['product_class_id'],
198
                            $addCartData['quantity']
199
                        )->save();
200
                    } catch (CartException $e) {
201
                        $this->addRequestError($e->getMessage());
202
                    }
203
204
                    $event = new EventArgs(
205
                        [
206
                            'form' => $addCartForm,
207
                            'Product' => $Product,
208
                        ],
209
                        $request
210
                    );
211
                    $this->eventDispatcher->dispatch(EccubeEvents::FRONT_PRODUCT_INDEX_COMPLETE, $event);
212
213
                    if ($event->getResponse() !== null) {
214
                        return $event->getResponse();
215
                    }
216
217
                    return $this->redirectToRoute('cart');
218
                }
219
            }
220
221 3
            $forms[$Product->getId()] = $addCartForm->createView();
222
        }
223
224
        // 表示件数
225 3
        $builder = $this->formFactory->createNamedBuilder(
226 3
            'disp_number',
227 3
            ProductListMaxType::class,
228 3
            null,
229
            [
230 3
                'required' => false,
231 3
                'label' => trans('productcontroller.label.result'),
232
                'allow_extra_fields' => true,
233
            ]
234
        );
235 3
        if ($request->getMethod() === 'GET') {
236 3
            $builder->setMethod('GET');
237
        }
238
239 3
        $event = new EventArgs(
240
            [
241 3
                'builder' => $builder,
242
            ],
243 3
            $request
244
        );
245 3
        $this->eventDispatcher->dispatch(EccubeEvents::FRONT_PRODUCT_INDEX_DISP, $event);
246
247 3
        $dispNumberForm = $builder->getForm();
248
249 3
        $dispNumberForm->handleRequest($request);
250
251
        // ソート順
252 3
        $builder = $this->formFactory->createNamedBuilder(
253 3
            'orderby',
254 3
            ProductListOrderByType::class,
255 3
            null,
256
            [
257 3
                'required' => false,
258 3
                'label' => trans('productcontroller.label.sort'),
259
                'allow_extra_fields' => true,
260
            ]
261
        );
262 3
        if ($request->getMethod() === 'GET') {
263 3
            $builder->setMethod('GET');
264
        }
265
266 3
        $event = new EventArgs(
267
            [
268 3
                'builder' => $builder,
269
            ],
270 3
            $request
271
        );
272 3
        $this->eventDispatcher->dispatch(EccubeEvents::FRONT_PRODUCT_INDEX_ORDER, $event);
273
274 3
        $orderByForm = $builder->getForm();
275
276 3
        $orderByForm->handleRequest($request);
277
278 3
        $Category = $searchForm->get('category_id')->getData();
279
280
        return [
281 3
            'subtitle' => $this->getPageTitle($searchData),
282 3
            'pagination' => $pagination,
283 3
            'search_form' => $searchForm->createView(),
284 3
            'disp_number_form' => $dispNumberForm->createView(),
285 3
            'order_by_form' => $orderByForm->createView(),
286 3
            'forms' => $forms,
287 3
            'Category' => $Category,
288
        ];
289
    }
290
291
    /**
292
     * 商品詳細画面.
293
     *
294
     * @Method("GET")
295
     * @Route("/products/detail/{id}", name="product_detail", requirements={"id" = "\d+"})
296
     * @Template("Product/detail.twig")
297
     * @ParamConverter("Product", options={"repository_method" = "findWithSortedClassCategories"})
298
     *
299
     * @param Request $request
300
     * @param Product $Product
301
     *
302
     * @return array
303
     */
304 11
    public function detail(Request $request, Product $Product)
305
    {
306 11
        if (!$this->checkVisibility($Product)) {
307
            throw new NotFoundHttpException();
308
        }
309
310 11
        $builder = $this->formFactory->createNamedBuilder(
311 11
            '',
312 11
            AddCartType::class,
313 11
            null,
314
            [
315 11
                'product' => $Product,
316
                'id_add_product_id' => false,
317
            ]
318
        );
319
320 11
        $event = new EventArgs(
321
            [
322 11
                'builder' => $builder,
323 11
                'Product' => $Product,
324
            ],
325 11
            $request
326
        );
327 11
        $this->eventDispatcher->dispatch(EccubeEvents::FRONT_PRODUCT_DETAIL_INITIALIZE, $event);
328
329 11
        $is_favorite = false;
330 11
        if ($this->isGranted('ROLE_USER')) {
331 2
            $Customer = $this->getUser();
332 2
            $is_favorite = $this->customerFavoriteProductRepository->isFavorite($Customer, $Product);
0 ignored issues
show
Documentation introduced by
$Customer is of type null|object, but the function expects a object<Eccube\Entity\Customer>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
333
        }
334
335
        return [
336 11
            'title' => $this->title,
337 11
            'subtitle' => $Product->getName(),
338 11
            'form' => $builder->getForm()->createView(),
339 11
            'Product' => $Product,
340 11
            'is_favorite' => $is_favorite,
341
        ];
342
    }
343
344
    /**
0 ignored issues
show
introduced by
Doc comment for parameter "$request" missing
Loading history...
introduced by
Doc comment for parameter "$Product" missing
Loading history...
345
     * お気に入り追加.
346
     *
347
     * @Route("/products/add_favorite/{id}", name="product_add_favorite", requirements={"id" = "\d+"})
348
     */
0 ignored issues
show
introduced by
Missing @return tag in function comment
Loading history...
349 3
    public function addFavorite(Request $request, Product $Product)
350
    {
351 3
        $this->checkVisibility($Product);
352
353 3
        $event = new EventArgs(
354
            [
355 3
                'Product' => $Product,
356
            ],
357 3
            $request
358
        );
359 3
        $this->eventDispatcher->dispatch(EccubeEvents::FRONT_PRODUCT_FAVORITE_ADD_INITIALIZE, $event);
360
361 3
        if ($this->isGranted('ROLE_USER')) {
362 2
            $Customer = $this->getUser();
363 2
            $this->customerFavoriteProductRepository->addFavorite($Customer, $Product);
0 ignored issues
show
Documentation introduced by
$Customer is of type null|object, but the function expects a object<Eccube\Entity\Customer>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
364 2
            $this->session->getFlashBag()->set('product_detail.just_added_favorite', $Product->getId());
365
366 2
            $event = new EventArgs(
367
                [
368 2
                    'Product' => $Product,
369
                ],
370 2
                $request
371
            );
372 2
            $this->eventDispatcher->dispatch(EccubeEvents::FRONT_PRODUCT_FAVORITE_ADD_COMPLETE, $event);
373
374 2
            return $this->redirectToRoute('product_detail', ['id' => $Product->getId()]);
375
        } else {
376
            // 非会員の場合、ログイン画面を表示
377
            //  ログイン後の画面遷移先を設定
378 1
            $this->setLoginTargetPath($this->generateUrl('product_add_favorite', ['id' => $Product->getId()]));
379 1
            $this->session->getFlashBag()->set('eccube.add.favorite', true);
0 ignored issues
show
Documentation introduced by
true is of type boolean, but the function expects a string|array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
380
381 1
            $event = new EventArgs(
382
                [
383 1
                    'Product' => $Product,
384
                ],
385 1
                $request
386
            );
387 1
            $this->eventDispatcher->dispatch(EccubeEvents::FRONT_PRODUCT_FAVORITE_ADD_COMPLETE, $event);
388
389 1
            return $this->redirectToRoute('mypage_login');
390
        }
391
    }
392
393
    /**
0 ignored issues
show
introduced by
Doc comment for parameter "$request" missing
Loading history...
introduced by
Doc comment for parameter "$Product" missing
Loading history...
394
     * カートに追加.
395
     *
396
     * @Method("POST")
397
     * @Route("/products/add_cart/{id}", name="product_add_cart", requirements={"id" = "\d+"})
398
     */
0 ignored issues
show
introduced by
Missing @return tag in function comment
Loading history...
399 36
    public function addCart(Request $request, Product $Product)
400
    {
401
        // エラーメッセージの配列
402 36
        $errorMessages = [];
403 36
        if (!$this->checkVisibility($Product)) {
404 1
            throw new NotFoundHttpException();
405
        }
406
407 35
        $builder = $this->formFactory->createNamedBuilder(
408 35
            '',
409 35
            AddCartType::class,
410 35
            null,
411
            [
412 35
                'product' => $Product,
413
                'id_add_product_id' => false,
414
            ]
415
        );
416
417 35
        $event = new EventArgs(
418
            [
419 35
                'builder' => $builder,
420 35
                'Product' => $Product,
421
            ],
422 35
            $request
423
        );
424 35
        $this->eventDispatcher->dispatch(EccubeEvents::FRONT_PRODUCT_CART_ADD_INITIALIZE, $event);
425
426
        /* @var $form \Symfony\Component\Form\FormInterface */
427 35
        $form = $builder->getForm();
428 35
        $form->handleRequest($request);
429
430 35
        if (!$form->isValid()) {
431
            throw new NotFoundHttpException();
432
        }
433
434 35
        $addCartData = $form->getData();
435
436 35
        log_info(
437 35
            'カート追加処理開始',
438
            [
439 35
                'product_id' => $Product->getId(),
440 35
                'product_class_id' => $addCartData['product_class_id'],
441 35
                'quantity' => $addCartData['quantity'],
442
            ]
443
        );
444
445
        // カートへ追加
446 35
        $this->cartService->addProduct($addCartData['product_class_id'], $addCartData['quantity']);
447
448
        // 明細の正規化
449 35
        $flow = $this->purchaseFlow;
450 35
        $Cart = $this->cartService->getCart();
451 35
        $result = $flow->calculate($Cart, new PurchaseContext($Cart, $this->getUser()));
452
453
        // 復旧不可のエラーが発生した場合は追加した明細を削除.
454 35
        if ($result->hasError()) {
455
            $this->cartService->removeProduct($addCartData['product_class_id']);
456
            foreach ($result->getErrors() as $error) {
457
                $errorMessages[] = $error->getMessage();
458
            }
459
        }
460
461 35
        foreach ($result->getWarning() as $warning) {
462 5
            $errorMessages[] = $warning->getMessage();
463
        }
464
465 35
        $this->cartService->save();
466
467 35
        log_info(
468 35
            'カート追加処理完了',
469
            [
470 35
                'product_id' => $Product->getId(),
471 35
                'product_class_id' => $addCartData['product_class_id'],
472 35
                'quantity' => $addCartData['quantity'],
473
            ]
474
        );
475
476 35
        $event = new EventArgs(
477
            [
478 35
                'form' => $form,
479 35
                'Product' => $Product,
480
            ],
481 35
            $request
482
        );
483 35
        $this->eventDispatcher->dispatch(EccubeEvents::FRONT_PRODUCT_CART_ADD_COMPLETE, $event);
484
485 35
        if ($event->getResponse() !== null) {
486
            return $event->getResponse();
487
        }
488
489 35
        if ($request->isXmlHttpRequest()) {
490
            // ajaxでのリクエストの場合は結果をjson形式で返す。
491
492
            // 初期化
493
            $done = null;
0 ignored issues
show
Unused Code introduced by
$done is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
494
            $messages = [];
495
496
            if (empty($errorMessages)) {
497
                // エラーが発生していない場合
498
                $done = true;
499
                array_push($messages, 'カートに追加しました。');
500
            } else {
501
                // エラーが発生している場合
502
                $done = false;
503
                $messages = $errorMessages;
504
            }
505
506
            return new JsonResponse(['done' => $done, 'messages' => $messages]);
507
        } else {
508
            // ajax以外でのリクエストの場合はカート画面へリダイレクト
509 35
            foreach ($errorMessages as $errorMessage) {
510 5
                $this->addRequestError($errorMessage);
511
            }
512
513 35
            return $this->redirectToRoute('cart');
514
        }
515
    }
516
517
    /**
518
     * ページタイトルの設定
519
     *
520
     * @param  null|array $searchData
521
     *
522
     * @return str
523
     */
524 3
    private function getPageTitle($searchData)
525
    {
526 3
        if (isset($searchData['name']) && !empty($searchData['name'])) {
527
            return trans('productcontroller.text.return.search');
528 3
        } elseif (isset($searchData['category_id']) && $searchData['category_id']) {
529 1
            return $searchData['category_id']->getName();
530
        } else {
531 2
            return trans('productcontroller.text.return.all_products');
532
        }
533
    }
534
535
    /**
536
     * 閲覧可能な商品かどうかを判定
537
     *
538
     * @param Product $Product
539
     *
540
     * @return boolean 閲覧可能な場合はtrue
541
     */
542 42
    private function checkVisibility(Product $Product)
543
    {
544 42
        $is_admin = $this->session->has('_security_admin');
545
546
        // 管理ユーザの場合はステータスやオプションにかかわらず閲覧可能.
547 42
        if (!$is_admin) {
548
            // 在庫なし商品の非表示オプションが有効な場合.
549
            // if ($this->BaseInfo->isOptionNostockHidden()) {
0 ignored issues
show
Unused Code Comprehensibility introduced by
65% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
550
            //     if (!$Product->getStockFind()) {
0 ignored issues
show
Unused Code Comprehensibility introduced by
70% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
551
            //         return false;
552
            //     }
553
            // }
554
            // 公開ステータスでない商品は表示しない.
555 42
            if ($Product->getStatus()->getId() !== ProductStatus::DISPLAY_SHOW) {
556 1
                return false;
557
            }
558
        }
559
560 42
        return true;
561
    }
562
}
563