Passed
Push — master ( fcde6a...31906f )
by Robson
01:43
created

Address   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Importance

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

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
    public function getUser(): 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
}