Bag   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 96
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 3
Bugs 1 Features 0
Metric Value
wmc 5
c 3
b 1
f 0
lcom 0
cbo 0
dl 0
loc 96
ccs 14
cts 14
cp 1
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 11 1
A getTest() 0 4 1
A getOptions() 0 4 1
A getParticipationFilter() 0 4 1
A getVariantChooser() 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\Test;
11
12
use PhpAb\Participation\Filter\FilterInterface;
13
use PhpAb\Variant\Chooser\ChooserInterface;
14
15
/**
16
 * The combination of a test with options.
17
 *
18
 * @package PhpAb
19
 */
20
class Bag
21
{
22
    /**
23
     * The test to execute.
24
     *
25
     * @var TestInterface
26
     */
27
    private $test;
28
29
    /**
30
     * The options for this test.
31
     *
32
     * @var array
33
     */
34
    private $options;
35
36
    /**
37
     * The participation filter that checks if a guest should participate in the test.
38
     *
39
     * @var FilterInterface
40
     */
41
    private $participationFilter;
42
43
    /**
44
     * The variant chooser that decides which variant of the test to use.
45
     *
46
     * @var ChooserInterface
47
     */
48
    private $variantChooser;
49
50
    /**
51
     * Initializes a new instance of this class.
52
     *
53
     * @param TestInterface $test The test
54
     * @param FilterInterface $participationFilter
55
     * @param ChooserInterface $variantChooser
56
     * @param array $options Additional options
57
     */
58 23
    public function __construct(
59
        TestInterface $test,
60
        FilterInterface $participationFilter,
61
        ChooserInterface $variantChooser,
62
        $options = []
63
    ) {
64 23
        $this->test = $test;
65 23
        $this->options = $options;
66 23
        $this->participationFilter = $participationFilter;
67 23
        $this->variantChooser = $variantChooser;
68 23
    }
69
70
    /**
71
     * Get the Test from the Bag
72
     *
73
     * @return TestInterface
74
     */
75 14
    public function getTest()
76
    {
77 14
        return $this->test;
78
    }
79
80
    /**
81
     * Get all Options for the Test.
82
     *
83
     * Options can be used for data which is not mandatory and
84
     * can be Implementation specific. Like Google-Experiments ID
85
     *
86
     * @return array
87
     */
88 2
    public function getOptions()
89
    {
90 2
        return $this->options;
91
    }
92
93
    /**
94
     * Get the Participation Strategy
95
     *
96
     * @return FilterInterface
97
     */
98 6
    public function getParticipationFilter()
99
    {
100 6
        return $this->participationFilter;
101
    }
102
103
    /**
104
     * Get the Variant Chooser.
105
     *
106
     * The Variant Chooser chooses the variant after the
107
     * Strategy allowed the user to participate in the test.
108
     *
109
     * @return ChooserInterface
110
     */
111 5
    public function getVariantChooser()
112
    {
113 5
        return $this->variantChooser;
114
    }
115
}
116