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

SessionVisitor::getExperiment()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 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