Goal   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 2
dl 0
loc 21
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A scopeActive() 0 8 2
1
<?php
2
3
namespace Reallyli\AB\Models;
4
5
use Illuminate\Support\Facades\Config;
6
use Illuminate\Database\Eloquent\Model as Eloquent;
7
8
class Goal extends Eloquent
9
{
10
    protected $fillable = ['name', 'experiment', 'count'];
11
12
    public function __construct(array $attributes = [])
13
    {
14
        parent::__construct($attributes);
15
16
        // Set the connection based on the config.
17
        $this->connection = Config::get('ab::connection');
18
    }
19
20
    public function scopeActive($query)
21
    {
22
        if ($experiments = Config::get('ab::experiments')) {
0 ignored issues
show
Unused Code introduced by
$experiments 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...
23
            return $query->whereIn('experiment', Config::get('ab::experiments'));
24
        }
25
26
        return $query;
27
    }
28
}
29