Passed
Push — main ( b61a30...1b59ca )
by Wagner
01:24
created

ProductCategory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A restaurant() 0 4 1
A __construct() 0 5 1
1
<?php
2
3
namespace WagnerMontanini\GoomerApi\Models;
4
5
use CoffeeCode\DataLayer\DataLayer;
6
use WagnerMontanini\GoomerApi\Models\Restaurant;
7
8
/**
9
 * Class ProductCategory
10
 * @package WagnerMontanini\GoomerApi\Models
11
 */
12
class ProductCategory extends DataLayer
13
{
14
    
15
    /**
16
     * ProductCategory constructor.
17
     */
18
    public function __construct()
19
    {
20
        parent::__construct(
21
            "products_categories",
22
            ["restaurant_id", "name"]
23
        );
24
    }
25
26
    public function restaurant(): ProductCategory
27
    {
28
        $this->restaurant = (new Restaurant())->findById($this->restaurant_id)->data();
0 ignored issues
show
Bug Best Practice introduced by
The property restaurant does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
Bug introduced by
$this->restaurant_id of type null|string is incompatible with the type integer expected by parameter $id of CoffeeCode\DataLayer\DataLayer::findById(). ( Ignorable by Annotation )

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

28
        $this->restaurant = (new Restaurant())->findById(/** @scrutinizer ignore-type */ $this->restaurant_id)->data();
Loading history...
Bug Best Practice introduced by
The property restaurant_id does not exist on WagnerMontanini\GoomerApi\Models\ProductCategory. Since you implemented __get, consider adding a @property annotation.
Loading history...
29
        return $this;
30
    }
31
32
}