Address   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A getUser() 0 4 1
1
<?php
2
3
namespace Example\Models;
4
5
use CoffeeCode\DataLayer\DataLayer;
6
7
/**
8
 * Class Address
9
 * @package Example\Models
10
 */
11
class Address extends DataLayer
12
{
13
    /**
14
     * Address constructor.
15
     */
16
    public function __construct()
17
    {
18
        parent::__construct("adresses", ["user_id"]);
19
    }
20
21
    /**
22
     * @return $this
23
     */
24
    public function getUser(): Address
25
    {
26
        $this->user = (new User())->findById($this->user_id)->data();
0 ignored issues
show
Bug introduced by
$this->user_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

26
        $this->user = (new User())->findById(/** @scrutinizer ignore-type */ $this->user_id)->data();
Loading history...
Bug Best Practice introduced by
The property user_id does not exist on Example\Models\Address. Since you implemented __get, consider adding a @property annotation.
Loading history...
Bug Best Practice introduced by
The property user does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
27
        return $this;
28
    }
29
}