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.
Completed
Push — master ( 9e7309...ca86c4 )
by Aden
39:37 queued 06:18
created

ModelDeleting   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 56
Duplicated Lines 25 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 1
cbo 3
dl 14
loc 56
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A beforeDelete() 0 3 1
A delete() 14 14 1
A doDelete() 0 6 1
A afterDelete() 0 3 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace LaravelFlare\Flare\Admin\Models\Traits;
4
5
use LaravelFlare\Flare\Events\ModelDelete;
6
use LaravelFlare\Flare\Events\AfterDelete;
7
use LaravelFlare\Flare\Events\BeforeDelete;
8
use LaravelFlare\Flare\Exceptions\ModelAdminWriteableException as WriteableException;
9
10
trait ModelDeleting
11
{
12
    /**
13
     * Method fired before the Delete action is undertaken.
14
     * 
15
     * @return
16
     */
17
    protected function beforeDelete()
18
    {
19
    }
20
21
    /**
22
     * Delete Action.
23
     *
24
     * Fires off beforeDelete(), doDelete() and afterDelete()
25
     * 
26
     * @param int $modelitemId
27
     * 
28
     * @return
29
     */
30 View Code Duplication
    public function delete($modelitemId)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
31
    {
32
        $this->find($modelitemId);
0 ignored issues
show
Bug introduced by
It seems like find() 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...
33
34
        event(new BeforeDelete($this));
35
36
        $this->beforeDelete();
37
38
        $this->doDelete();
39
40
        $this->afterDelete();
41
42
        event(new AfterDelete($this));
43
    }
44
45
    /**
46
     * The actual delete action.
47
     * 
48
     * @return
49
     */
50
    private function doDelete()
51
    {
52
        $this->model->delete();
53
54
        event(new ModelDelete($this));
55
    }
56
57
    /**
58
     * Method fired after the Delete action is complete.
59
     * 
60
     * @return
61
     */
62
    protected function afterDelete()
63
    {
64
    }
65
}
66