Passed
Push — master ( cd8e91...88725a )
by Robson
07:25
created

Address::user()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
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
    public function user(): Address
22
    {
23
        $this->user = (new User())->findById($this->user_id)->data();
0 ignored issues
show
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...
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 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

23
        $this->user = (new User())->findById(/** @scrutinizer ignore-type */ $this->user_id)->data();
Loading history...
24
        return $this;
25
    }
26
}