Relation::getUsersRelationValue()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

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 0
cts 2
cp 0
crap 2
rs 10
1
<?php
2
3
namespace App\Models\Concerns\Company;
4
5
use Illuminate\Database\Eloquent\Collection;
6
use Illuminate\Database\Eloquent\Relations\HasMany;
7
8
/**
9
 * @property-read \Illuminate\Database\Eloquent\Collection<\App\Models\User> $users
10
 *
11
 * @see \App\Models\Company
12
 */
13
trait Relation
14
{
15
    /**
16
     * Define a one-to-many relationship with App\Models\User.
17
     *
18
     * @return \Illuminate\Database\Eloquent\Relations\HasMany
19
     */
20
    public function users(): HasMany
21
    {
22
        return $this->hasMany(User::class);
0 ignored issues
show
Bug introduced by
The type App\Models\Concerns\Company\User was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
Bug introduced by
It seems like hasMany() 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

22
        return $this->/** @scrutinizer ignore-call */ hasMany(User::class);
Loading history...
23
    }
24
25
    /**
26
     * Return collection of \App\Models\User model relation value.
27
     *
28
     * @return \Illuminate\Database\Eloquent\Collection<\App\Models\User>
29
     */
30
    public function getUsersRelationValue(): Collection
31
    {
32
        return $this->getCollectionValue('users', User::class);
0 ignored issues
show
Bug introduced by
It seems like getCollectionValue() 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

32
        return $this->/** @scrutinizer ignore-call */ getCollectionValue('users', User::class);
Loading history...
33
    }
34
35
    /**
36
     * Set collection of \App\Models\User model relation value.
37
     *
38
     * @param  \Illuminate\Database\Eloquent\Collection<\App\Models\User>  $users
39
     * @return $this
40
     */
41
    public function setUsersRelationValue(Collection $users)
42
    {
43
        if ($this->isCollectionValid($users, User::class)) {
0 ignored issues
show
Bug introduced by
It seems like isCollectionValid() 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

43
        if ($this->/** @scrutinizer ignore-call */ isCollectionValid($users, User::class)) {
Loading history...
44
            $this->setRelation('users', $users);
0 ignored issues
show
Bug introduced by
It seems like setRelation() 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

44
            $this->/** @scrutinizer ignore-call */ 
45
                   setRelation('users', $users);
Loading history...
45
        }
46
47
        return $this;
48
    }
49
}
50