Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

Completed
Push — master ( 7fd57f...ddf3cc )
by Mark
02:55
created

Activity   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 80
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 80
rs 10
c 0
b 0
f 0
wmc 7
lcom 2
cbo 1

4 Methods

Rating   Name   Duplication   Size   Complexity  
A eventName() 0 11 4
A account() 0 4 1
A model() 0 4 1
A log() 0 12 1
1
<?php
2
3
namespace App\Model;
4
5
use App\Classes\Interfaces\Linkable;
6
use App\Classes\Interfaces\Linker;
7
use Illuminate\Database\Eloquent\Model;
8
9
/**
10
 * Class Activity
11
 *
12
 * @property string $message
13
 * @property int $event
14
 *
15
 * @property Linkable $model
16
 * @property Account $account
17
 *
18
 * @package App
19
 */
20
class Activity extends Model
21
{
22
23
    /**
24
     * @var int
25
     */
26
    public static $deleted = 0;
27
    /**
28
     * @var int
29
     */
30
    public static $created = 1;
31
    /**
32
     * @var int
33
     */
34
    public static $updated = 2;
35
36
    /**
37
     * The table associated with the model.
38
     *
39
     * @var string
40
     */
41
    protected $table = 'activity';
42
43
    /**
44
     * The attributes that are not mass assignable.
45
     *
46
     * @var array
47
     */
48
    protected $guarded = [];
49
50
    /**
51
     * @return bool|string
0 ignored issues
show
Documentation introduced by
Consider making the return type a bit more specific; maybe use string|false.

This check looks for the generic type array as a return type and suggests a more specific type. This type is inferred from the actual code.

Loading history...
52
     */
53
    public function eventName()
54
    {
55
        switch ($this->event)
56
        {
57
            case self::$deleted : return 'deleted';
0 ignored issues
show
Coding Style introduced by
There must be no space before the colon in a CASE statement

As per the PSR-2 coding standard, there must not be a space in front of the colon in case statements.

switch ($selector) {
    case "A": //right
        doSomething();
        break;
    case "B" : //wrong
        doSomethingElse();
        break;
}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
Coding Style introduced by
The case body in a switch statement must start on the line following the statement.

According to the PSR-2, the body of a case statement must start on the line immediately following the case statement.

switch ($expr) {
case "A":
    doSomething(); //right
    break;
case "B":

    doSomethingElse(); //wrong
    break;

}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
Coding Style introduced by
Terminating statement must be on a line by itself

As per the PSR-2 coding standard, the break (or other terminating) statement must be on a line of its own.

switch ($expr) {
     case "A":
         doSomething();
         break; //wrong
     case "B":
         doSomething();
         break; //right
     case "C:":
         doSomething();
         return true; //right
 }

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
58
            case self::$created : return 'created';
0 ignored issues
show
Coding Style introduced by
There must be no space before the colon in a CASE statement

As per the PSR-2 coding standard, there must not be a space in front of the colon in case statements.

switch ($selector) {
    case "A": //right
        doSomething();
        break;
    case "B" : //wrong
        doSomethingElse();
        break;
}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
Coding Style introduced by
The case body in a switch statement must start on the line following the statement.

According to the PSR-2, the body of a case statement must start on the line immediately following the case statement.

switch ($expr) {
case "A":
    doSomething(); //right
    break;
case "B":

    doSomethingElse(); //wrong
    break;

}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
Coding Style introduced by
Terminating statement must be on a line by itself

As per the PSR-2 coding standard, the break (or other terminating) statement must be on a line of its own.

switch ($expr) {
     case "A":
         doSomething();
         break; //wrong
     case "B":
         doSomething();
         break; //right
     case "C:":
         doSomething();
         return true; //right
 }

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
59
            case self::$updated : return 'updated';
0 ignored issues
show
Coding Style introduced by
There must be no space before the colon in a CASE statement

As per the PSR-2 coding standard, there must not be a space in front of the colon in case statements.

switch ($selector) {
    case "A": //right
        doSomething();
        break;
    case "B" : //wrong
        doSomethingElse();
        break;
}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
Coding Style introduced by
The case body in a switch statement must start on the line following the statement.

According to the PSR-2, the body of a case statement must start on the line immediately following the case statement.

switch ($expr) {
case "A":
    doSomething(); //right
    break;
case "B":

    doSomethingElse(); //wrong
    break;

}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
Coding Style introduced by
Terminating statement must be on a line by itself

As per the PSR-2 coding standard, the break (or other terminating) statement must be on a line of its own.

switch ($expr) {
     case "A":
         doSomething();
         break; //wrong
     case "B":
         doSomething();
         break; //right
     case "C:":
         doSomething();
         return true; //right
 }

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
60
        }
61
62
        return false;
63
    }
64
65
    /**
66
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
67
     */
68
    public function account()
69
    {
70
        return $this->belongsTo(Account::class, 'account_id', 'id');
71
    }
72
73
    /**
74
     * @return Linker
75
     */
76
    public function model()
77
    {
78
        return $this->morphTo()->withTrashed();
79
    }
80
81
    /**
82
     * @param int $action
83
     * @param Model $model
84
     * @param Account|null $account
85
     * @return mixed
0 ignored issues
show
Documentation introduced by
Consider making the return type a bit more specific; maybe use boolean.

This check looks for the generic type array as a return type and suggests a more specific type. This type is inferred from the actual code.

Loading history...
86
     */
87
    public function log(int $action, Model $model, Account $account = null)
88
    {
89
        $this->setAttribute('event', $action);
90
91
        $this->setAttribute('model_id', $model->getKey());
92
93
        $this->setAttribute('model_type', $model->getMorphClass());
94
95
        $this->setAttribute('account_id', $account->getKey());
0 ignored issues
show
Bug introduced by
It seems like $account is not always an object, but can also be of type null. Maybe add an additional type check?

If a variable is not always an object, we recommend to add an additional type check to ensure your method call is safe:

function someFunction(A $objectMaybe = null)
{
    if ($objectMaybe instanceof A) {
        $objectMaybe->doSomething();
    }
}
Loading history...
96
97
        return $this->save();
98
    }
99
}
100