Relation::company()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
3
namespace App\Models\Concerns\User;
4
5
use App\Models\Company;
6
use Illuminate\Database\Eloquent\Relations\BelongsTo;
7
8
/**
9
 * @property int $company_id Foreign key of \App\Models\Company.
10
 * @property-read \App\Models\Company $company
11
 *
12
 * @see \App\Models\User
13
 */
14
trait Relation
15
{
16
    /**
17
     * Define an inverse one-to-one or many relationship with \App\Models\Company.
18
     *
19
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
20
     */
21 8
    public function company(): BelongsTo
22
    {
23 8
        return $this->belongsTo(Company::class);
0 ignored issues
show
Bug introduced by
It seems like belongsTo() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

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

23
        return $this->/** @scrutinizer ignore-call */ belongsTo(Company::class);
Loading history...
24
    }
25
26
    /**
27
     * Return \App\Models\Company model relation value.
28
     *
29
     * @return \App\Models\Company
30
     */
31
    public function getCompanyRelationValue(): Company
32
    {
33
        return $this->getRelationValue('company');
0 ignored issues
show
Bug introduced by
It seems like getRelationValue() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

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

33
        return $this->/** @scrutinizer ignore-call */ getRelationValue('company');
Loading history...
34
    }
35
36
    /**
37
     * Set \App\Models\Company model relation value.
38
     *
39
     * @param  \App\Models\Company  $company
40
     * @return $this
41
     */
42 1
    public function setCompanyRelationValue(Company $company)
43
    {
44 1
        $this->company()->associate($company);
45
46 1
        return $this;
47
    }
48
}
49