ParticipationEvent   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 71
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 3
Bugs 1 Features 2
Metric Value
wmc 4
c 3
b 1
f 2
lcom 0
cbo 0
dl 0
loc 71
ccs 11
cts 11
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A getTest() 0 4 1
A getVariant() 0 4 1
A isNew() 0 4 1
1
<?php
2
/**
3
 * This file is part of phpab/phpab. (https://github.com/phpab/phpab)
4
 *
5
 * @link https://github.com/phpab/phpab for the canonical source repository
6
 * @copyright Copyright (c) 2015-2016 phpab. (https://github.com/phpab/)
7
 * @license https://raw.githubusercontent.com/phpab/phpab/master/LICENSE.md MIT
8
 */
9
10
namespace PhpAb\Event;
11
12
use PhpAb\Test\TestInterface;
13
use PhpAb\Variant\VariantInterface;
14
15
/**
16
 * Holds information about a participation event which is needed for further processing.
17
 *
18
 * @package PhpAb
19
 */
20
class ParticipationEvent
21
{
22
    /**
23
     * This Event will be fired once a participation for a user is registered.
24
     */
25
    const PARTICIPATION = 'phpab.participation';
26
27
    /**
28
     * The test to participate in.
29
     *
30
     * @var TestInterface
31
     */
32
    private $test;
33
34
    /**
35
     * The variant that is chosen.
36
     *
37
     * @var VariantInterface
38
     */
39
    private $variant;
40
41
    /**
42
     * A flag indicating whether or not the user already participates in the test.
43
     *
44
     * @var boolean
45
     */
46
    private $isNew;
47
48
    /**
49
     * Initializes a new instance of this class.
50
     * @param TestInterface $test The Test the participation was registered for
51
     * @param VariantInterface $variant The Variant the user is associated with
52
     * @param boolean $isNew Indicates weather the user is new or has an old participation from the storage.
53
     */
54 4
    public function __construct(TestInterface $test, VariantInterface $variant, $isNew)
55
    {
56 4
        $this->test = $test;
57 4
        $this->variant = $variant;
58 4
        $this->isNew = $isNew;
59 4
    }
60
61
    /**
62
     * Get the Test the participation was registered for
63
     *
64
     * @return TestInterface
65
     */
66 1
    public function getTest()
67
    {
68 1
        return $this->test;
69
    }
70
71
    /**
72
     * Get the Variant the user is associated with
73
     *
74
     * @return VariantInterface
75
     */
76 1
    public function getVariant()
77
    {
78 1
        return $this->variant;
79
    }
80
81
    /**
82
     * Checks weather the participation of the user is new
83
     *
84
     * @return boolean
85
     */
86 2
    public function isNew()
87
    {
88 2
        return $this->isNew;
89
    }
90
}
91