GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

HasManyAttachments   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 19
rs 10
c 0
b 0
f 0
wmc 1
lcom 0
cbo 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A attachments() 0 4 1
1
<?php namespace Afrittella\BackProject\Traits;
2
3
use Afrittella\BackProject\Models\Attachment;
4
use Afrittella\BackProject\Traits\Attachable;
5
6
trait HasManyAttachments {
7
    /*
8
     * Indicates if is a one to many relation or one to one
9
     */
10
    protected $multi = true;
11
12
    use Attachable;
13
14
    /**
15
     * Gel all attachments for this model
16
     *
17
     *  @return \Illuminate\Database\Eloquent\Relations\MorphMany
18
     */
19
20
    public function attachments()
21
    {
22
        return $this->morphToMany( Attachment::class, 'attachable' )->orderBy('is_main', 'desc');
0 ignored issues
show
Bug introduced by
It seems like morphToMany() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
23
    }
24
}
25