StatsConfig::getEpochEnabled()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
ccs 0
cts 4
cp 0
crap 2
1
<?php
2
/**
3
 * @author Oleg Krivtsov <[email protected]>
4
 * @date 14 May 2018
5
 * @copyright (c) 2018, Web Marketing ROI
6
 */
7
namespace WebMarketingROI\OptimizelyPHP\Resource\v2;
8
9
use WebMarketingROI\OptimizelyPHP\Exception;
10
11
/**
12
 * Optimizely experiment results stats config.
13
 */
14
class StatsConfig
15
{
16
    /**
17
     * 
18
     * @var number 
19
     */
20
    private $confidenceLevel;
21
    
22
    /**
23
     * The type of test to compare the variant to baseline. Can be absolute or relative
24
     * @var string 
25
     */
26
    private $differenceType;
27
    
28
    /**
29
     * Indicates if epoch-based statistics were used
30
     * @var boolean 
31
     */
32
    private $epochEnabled;
33
    
34
    /**
35
     * Constructor.
36
     */
37
    public function __construct($options = array())
38
    {
39
        foreach ($options as $name=>$value) {
40
            switch ($name) {                
41
                case 'confidence_level': $this->setConfidenceLevel($value); break;
42
                case 'difference_type': $this->setDifferenceType($value); break;
43
                case 'epoch_enabled': $this->setEpochEnabled($value); break;
44
                default:
45
                    throw new Exception('Unknown option found in the StatsConfig entity: ' . $name);
46
            }
47
        }
48
    }
49
    
50
    /**
51
     * Returns this object as array.
52
     */
53
    public function toArray()
54
    {
55
        $options = array(
56
            'confidence_level' => $this->getConfidenceLevel(),
57
            'difference_type' => $this->getDifferenceType(),
58
            'epoch_enabled' => $this->getEpochEnabled(),
59
        );
60
        
61
        // Remove options with empty values
62
        $cleanedOptions = array();
63
        foreach ($options as $name=>$value) {
64
            if ($value!==null)
65
                $cleanedOptions[$name] = $value;
66
        }
67
        
68
        return $cleanedOptions;
69
    }
70
    
71
    public function getConfidenceLevel()
72
    {
73
        return $this->confidenceLevel;
74
    }
75
    
76
    public function setConfidenceLevel($confidenceLevel)
77
    {
78
        $this->confidenceLevel = $confidenceLevel;
79
    }
80
    
81
    public function getDifferenceType()
82
    {
83
        return $this->differenceType;
84
    }
85
    
86
    public function setDifferenceType($differenceType)
87
    {
88
        $this->differenceType = $differenceType;
89
    }
90
    
91
    public function getEpochEnabled()
92
    {
93
        return $this->epochEnabled;
94
    }
95
    
96
    public function setEpochEnabled($epochEnabled)
97
    {
98
        $this->epochEnabled = $epochEnabled;
99
    }
100
}
101
102
103
104
105
106
107
108
109
110
111