Completed
Pull Request — master (#17)
by
unknown
14:51
created

SessionVisitor::setExperiment()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 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
    public function getExperiment()
17
    {
18
        return session(self::SESSION_KEY_EXPERIMENT);
19
    }
20
21
    public function setExperiment(Experiment $next)
22
    {
23
        session([self::SESSION_KEY_EXPERIMENT => $next]);
24
    }
25
}
26