Relation   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Test Coverage

Coverage 71.43%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 33
ccs 5
cts 7
cp 0.7143
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getCompanyRelationValue() 0 3 1
A company() 0 3 1
A setCompanyRelationValue() 0 5 1
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