Experiment   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A goals() 0 4 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 Experiment extends Eloquent
9
{
10
    protected $fillable = ['name', 'visitors', 'engagement'];
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 goals()
21
    {
22
        return $this->hasMany('Reallyli\AB\Models\Goal', 'experiment', 'name');
23
    }
24
25
    public function scopeActive($query)
26
    {
27
        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...
28
            return $query->whereIn('name', Config::get('ab::experiments'));
29
        }
30
31
        return $query;
32
    }
33
}
34