Conditions | 9 |
Paths | 1 |
Total Lines | 32 |
Code Lines | 15 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 1 |
1 | <?php namespace jlourenco\support\Traits; |
||
12 | public static function bootCreation() |
||
13 | { |
||
14 | |||
15 | // create a event to happen on deleting |
||
16 | static::deleting(function($table) { |
||
17 | if (class_exists('Cartalyst\Sentinel\Laravel\Facades\Sentinel')) |
||
18 | $table->deleted_by = Sentinel::getUser()->id; |
||
19 | else |
||
20 | $table->deleted_by = Auth::user()->id; |
||
21 | }); |
||
22 | |||
23 | // create a event to happen on saving |
||
24 | static::saving(function($table) { |
||
25 | |||
26 | if (class_exists('Cartalyst\Sentinel\Laravel\Facades\Sentinel')) |
||
27 | { |
||
28 | $table->modified_by = Sentinel::getUser()->id; |
||
29 | |||
30 | if ($user = Sentinel::check() && ($table->created_by == null || !($table->created_by > 0))) |
||
31 | $table->created_by = Sentinel::getUser()->id; |
||
32 | } |
||
33 | else |
||
34 | { |
||
35 | $table->modified_by = Auth::user()->id; |
||
36 | |||
37 | if (!Auth::guest() && ($table->created_by == null || !($table->created_by > 0))) |
||
38 | $table->created_by = Auth::user()->id; |
||
39 | } |
||
40 | |||
41 | }); |
||
42 | |||
43 | } |
||
44 | |||
45 | } |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
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.