• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

optimizely / php-sdk / 4388568943

pending completion
4388568943

Pull #261

github

GitHub
Merge 222c44f04 into fa9a3bf88
Pull Request #261: [FSSDK-8963] doc: Full Stack to Feature Experimentation Rename

2592 of 2666 relevant lines covered (97.22%)

64.22 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

60.71
/src/Optimizely/Entity/FeatureVariable.php
1
<?php
2
/**
3
 * Copyright 2017, 2019-2020 Optimizely
4
 *
5
 * Licensed under the Apache License, Version 2.0 (the "License");
6
 * you may not use this file except in compliance with the License.
7
 * You may obtain a copy of the License at
8
 *
9
 * http://www.apache.org/licenses/LICENSE-2.0
10
 *
11
 * Unless required by applicable law or agreed to in writing, software
12
 * distributed under the License is distributed on an "AS IS" BASIS,
13
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
 * See the License for the specific language governing permissions and
15
 * limitations under the License.
16
 */
17

18
namespace Optimizely\Entity;
19

20
class FeatureVariable
21
{
22

23
    // Feature variable primitive types
24
    const BOOLEAN_TYPE = 'boolean';
25
    const DOUBLE_TYPE = 'double';
26
    const INTEGER_TYPE = 'integer';
27
    const JSON_TYPE = 'json';
28
    const STRING_TYPE = 'string';
29

30
    /**
31
     * variable to hold the feature variable ID
32
     *
33
     * @var String
34
     */
35
    private $_id;
36

37
    /**
38
     * variable to hold the feature variable key
39
     *
40
     * @var String
41
     */
42
    private $_key;
43

44
    /**
45
     * variable denoting what primitive type the variable is. Will be one of 4 possible values:
46
     * a. boolean
47
     * b. string
48
     * c. integer
49
     * d. double
50
     * e. json
51
     *
52
     * @var String
53
     */
54
    private $_type;
55

56
    /**
57
     * variable containing the string representation of the default value for the feature variable.
58
     * This is the variable value that should be returned if the user is not bucketed into any variations
59
     * or fails the audience rules.
60
     *
61
     * @var String
62
     */
63
    private $_defaultValue;
64

65

66
    public function __construct($id = null, $key = null, $type = null, $defaultValue = null)
67
    {
68
        $this->_id = $id;
363✔
69
        $this->_key = $key;
363✔
70
        $this->_type = $type;
363✔
71
        $this->_defaultValue = $defaultValue;
363✔
72
    }
363✔
73

74
    /**
75
     * @return String Feature variable ID
76
     */
77
    public function getId()
78
    {
79
        return $this->_id;
45✔
80
    }
81

82
    /**
83
     * @param String $id Feature variable ID
84
     */
85
    public function setId($id)
86
    {
87
        $this->_id = $id;
363✔
88
    }
363✔
89

90
    /**
91
     * @return String Feature variable Key
92
     */
93
    public function getKey()
94
    {
95
        return $this->_key;
363✔
96
    }
97

98
    /**
99
     * @param String $key Feature variable Key
100
     */
101
    public function setKey($key)
102
    {
103
        $this->_key = $key;
363✔
104
    }
363✔
105

106
    /**
107
     * @return String Feature variable primitive type
108
     */
109
    public function getType()
110
    {
111
        return $this->_type;
66✔
112
    }
113

114
    /**
115
     * @param String $type Feature variable primitive type
116
     */
117
    public function setType($type)
118
    {
119
        $this->_type = $type;
363✔
120
    }
363✔
121

122
    /**
123
     * @return String Default value of the feature variable
124
     */
125
    public function getDefaultValue()
126
    {
127
        return $this->_defaultValue;
65✔
128
    }
129

130
    /**
131
     * @param String $value Default value of the feature variable
132
     */
133
    public function setDefaultValue($value)
134
    {
135
        $this->_defaultValue = $value;
363✔
136
    }
363✔
137

138
    /**
139
     * Returns feature variable method name based on
140
     * feature variable type.
141
     *
142
     * @param String $type Feature variable type.
143
     */
144
    public static function getFeatureVariableMethodName($type)
145
    {
146
        switch ($type) {
147
            case FeatureVariable::BOOLEAN_TYPE:
×
148
                return "getFeatureVariableBoolean";
×
149
            case FeatureVariable::DOUBLE_TYPE:
×
150
                return "getFeatureVariableDouble";
×
151
            case FeatureVariable::INTEGER_TYPE:
×
152
                return "getFeatureVariableInteger";
×
153
            case FeatureVariable::JSON_TYPE:
×
154
                return "getFeatureVariableJSON";
×
155
            case FeatureVariable::STRING_TYPE:
×
156
                return "getFeatureVariableString";
×
157
            default:
158
                return null;
×
159
        }
160
    }
161
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc