Completed
Pull Request — master (#17)
by
unknown
08:59 queued 07:53
created

SessionVisitor   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 71.43%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 0
dl 0
loc 19
ccs 5
cts 7
cp 0.7143
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A hasExperiment() 0 4 1
A getExperiment() 0 4 1
A setExperiment() 0 4 1
1
<?php
2
3
namespace Ben182\AbTesting\Models;
4
5
use Ben182\AbTesting\Contracts\VisitorInterface;
6
7
class SessionVisitor implements VisitorInterface
8
{
9
    const SESSION_KEY_EXPERIMENT = 'ab_testing_experiment';
10
11
    public function hasExperiment()
12
    {
13
        return (bool) session(self::SESSION_KEY_EXPERIMENT);
14
    }
15
16 39
    public function getExperiment()
17
    {
18 39
        return session(self::SESSION_KEY_EXPERIMENT);
19
    }
20
21 39
    public function setExperiment(Experiment $next)
22
    {
23 39
        session([self::SESSION_KEY_EXPERIMENT => $next]);
24 39
    }
25
}
26