Completed
Push — master ( 03841e...c8ea4b )
by Sherif
05:27
created

NotificationRepository   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 4
c 2
b 0
f 0
lcom 0
cbo 2
dl 0
loc 34
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getModel() 0 5 2
A notified() 0 4 1
A notifyAll() 0 4 1
1
<?php namespace App\Modules\Notifications\Repositories;
2
3
use App\Modules\Core\AbstractRepositories\AbstractRepository;
4
5
class NotificationRepository extends AbstractRepository
6
{
7
	/**
8
	 * Return the model full namespace.
9
	 * 
10
	 * @return string
11
	 */
12
	protected function getModel()
13
	{
14
        $apiVersion = \Request::header('api-version') ?: 1;
0 ignored issues
show
Unused Code introduced by
$apiVersion is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
15
		return 'App\Modules\Notifications\Notification';
16
	}
17
18
	/**
19
     * Set the notification notified to true.
20
     * 
21
     * @param  integer  $id
22
     * @return object
23
     */
24
    public function notified($id)
25
    {
26
        return $this->save(['id' => $id, 'notified' => 1]);
27
    }
28
29
    /**
30
     * Set the notification notified to all.
31
     * 
32
     * @return void
33
     */
34
    public function notifyAll()
35
    {
36
        \Core::notifications()->update(false, ['notified' => 1], 'notified');
37
    }
38
}
39