WrapItPushRequester   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 42.31 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 26.67%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 11
loc 26
ccs 4
cts 15
cp 0.2667
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A get() 0 3 1
A post() 11 11 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace WrapIt\Http;
4
5
use WrapIt\Exceptions\WrapItParameterException;
6
7
/**
8
 * Class WrapItPushRequester
9
 *
10
 * @package WrapIt
11
 */
12
class WrapItPushRequester extends Requester {
13
14
    private $access_token = null;
15
16 12
    public function __construct($domain, $token) {
17 12
        $this->domain = $domain;
18 12
        $this->access_token = $token;
19 12
    }
20
21
    public function get($api, $data = array()) {
22
        throw new WrapItParameterException("GET not alowed with this requester");
23
    }
24
25 View Code Duplication
    public function post($api, $data) {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
26
        $api = ltrim($api, "/");
27
        return $this->request(array(
28
            "url" => "https://" . $this->domain . "/" . $api,
29
            "post" => $data,
30
            "body_type" => "applicaton/json",
31
            "headers" => array(
32
                "Authorization: Bearer " . $this->access_token
33
            )
34
        ));
35
    }
36
37
}
38