Passed
Pull Request — master (#1)
by
unknown
01:35
created

Address::findByUser()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 2
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("address", [], 'address_id');
19
    }
20
21
    /**
22
     * @param int    $user_id
23
     * @param string $columns
24
     * @return Address|null
25
     */
26
    public function findByUser(int $user_id, string $columns = '*'): ?Address
27
    {
28
        return $this->find("user_id = :id", "id={$user_id}", $columns)->fetch();
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->find('user..._id, $columns)->fetch() could return the type array which is incompatible with the type-hinted return Example\Models\Address|null. Consider adding an additional type-check to rule them out.
Loading history...
29
    }
30
}