Code Duplication    Length = 26-28 lines in 2 locations

lib/WebMarketingROI/OptimizelyPHP/Service/v2/Projects.php 1 location

@@ 115-140 (lines=26) @@
112
     * @return Result
113
     * @throws Exception
114
     */
115
    public function update($projectId, $project) 
116
    {
117
        $projectId = (string)$projectId;
118
        
119
        if (!preg_match('/\d+/', $projectId)) {
120
            throw new Exception("A positive integer project ID expected, while got $projectId");
121
        }
122
        
123
        if ($projectId<0) {
124
            throw new Exception("A positive project ID expected");
125
        }
126
        
127
        if (!($project instanceOf Project)) {
128
            throw new Exception("Expected argument of type Project");
129
        }
130
        
131
        $postData = $project->toArray();
132
                
133
        $result = $this->client->sendApiRequest("/projects/$projectId", array(), 
134
                'PATCH', $postData);
135
        
136
        $project = new Project($result->getDecodedJsonData());
137
        $result->setPayload($project);
138
        
139
        return $result;
140
    }
141
}
142
143

lib/WebMarketingROI/OptimizelyPHP/Service/v2/Experiments.php 1 location

@@ 170-197 (lines=28) @@
167
     * @return Result
168
     * @throws Exception
169
     */
170
    public function update($experimentId, $experiment, $action) 
171
    {
172
        if (!is_int($experimentId)) {
173
            throw new Exception("Expected argument of type Experiment");
174
        }
175
        
176
        if ($experimentId<0) {
177
            throw new Exception("Expected positive experiment ID argument");
178
        }
179
        
180
        if (!($experiment instanceOf Experiment)) {
181
            throw new Exception("Expected argument of type Experiment");
182
        }
183
        
184
        $queryParams = array(
185
            'action' => $action
186
        );
187
        
188
        $postData = $experiment->toArray();
189
              
190
        $result = $this->client->sendApiRequest("/experiments/$experimentId", $queryParams, 'PATCH', 
191
                $postData);
192
        
193
        $experiment = new Experiment($result->getDecodedJsonData());
194
        $result->setPayload($experiment);
195
        
196
        return $result;
197
    }
198
    
199
    /**
200
     * Delete Experiment by ID