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.

ModelDeleting   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 56
Duplicated Lines 25 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 4
c 0
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
9
trait ModelDeleting
10
{
11
    /**
12
     * Method fired before the Delete action is undertaken.
13
     * 
14
     * @return
15
     */
16
    protected function beforeDelete()
17
    {
18
    }
19
20
    /**
21
     * Delete Action.
22
     *
23
     * Fires off beforeDelete(), doDelete() and afterDelete()
24
     * 
25
     * @param int $modelitemId
26
     * 
27
     * @return
28
     */
29 View Code Duplication
    public function delete($modelitemId)
30
    {
31
        $this->find($modelitemId);
32
33
        event(new BeforeDelete($this));
34
35
        $this->beforeDelete();
36
37
        $this->doDelete();
38
39
        $this->afterDelete();
40
41
        event(new AfterDelete($this));
42
    }
43
44
    /**
45
     * The actual delete action.
46
     * 
47
     * @return
48
     */
49
    private function doDelete()
50
    {
51
        $this->model->delete();
52
53
        event(new ModelDelete($this));
54
    }
55
56
    /**
57
     * Method fired after the Delete action is complete.
58
     * 
59
     * @return
60
     */
61
    protected function afterDelete()
62
    {
63
    }
64
}
65