Test Failed
Push — master ( a84a97...6a5aa6 )
by Gianluca
07:16
created

ShopSingleProductController   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 10
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 6
c 1
b 0
f 0
dl 0
loc 10
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A page() 0 8 2
1
<?php
2
3
4
namespace Mongi\Mongicommerce\Http\Controllers\shop;
5
6
7
use Mongi\Mongicommerce\Http\Controllers\Controller;
8
use Mongi\Mongicommerce\Libraries\Template;
9
use Mongi\Mongicommerce\Models\Product;
10
11
use Mongi\Mongicommerce\Models\ProductItem;
12
use Mongi\Mongicommerce\Models\ProductItemDetail;
13
14
class ShopSingleProductController extends Controller
15
{
16
     public function page($id,$product_item_id = null){
17
         $product = Product::find($id);
18
         $details_fields = Template::getDetailsFields($product);
0 ignored issues
show
Bug introduced by
It seems like $product can also be of type null; however, parameter $product of Mongi\Mongicommerce\Libr...ate::getDetailsFields() does only seem to accept Mongi\Mongicommerce\Models\Product, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

18
         $details_fields = Template::getDetailsFields(/** @scrutinizer ignore-type */ $product);
Loading history...
19
         if($product_item_id != null){
20
             $product = ProductItem::find($product_item_id);
21
         }
22
23
         return view('mongicommerce.pages.single-product',compact('product','details_fields'));
24
     }
25
}
26