Passed
Push — master ( c19fc7...328aea )
by Bence
04:43
created

WrapItApiHelper::request()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
ccs 0
cts 6
cp 0
rs 9.4285
cc 1
eloc 5
nc 1
nop 2
crap 2
1
<?php
2
3
namespace WrapIt\Helpers;
4
5
use WrapIt\WrapIt;
6
use WrapIt\Exceptions\WrapItParameterException;
7
use WrapIt\Exceptions\WrapItResponseException;
8
use WrapIt\Http\WrapItApiRequester;
9
10
/**
11
 * Class WrapItApiHelper
12
 *
13
 * @package WrapIt
14
 */
15
class WrapItApiHelper {
16
17
    private $client_id = null;
18
    private $client_secret = null;
19
20
    private $requester;
21
22 View Code Duplication
    public function __construct($wi) {
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...
23
        if (!($wi instanceof WrapIt)) {
24
            throw new WrapItParameterException("WrapIt class required");
25
        }
26
27
        $this->client_id = $wi->getClientId();
28
        $this->client_secret = $wi->getClientSecret();
29
        $this->requester = new WrapItApiRequester($wi->getDomain());
30
    }
31
32
    public function request($api, $data) {
33
        return $this->requester->post($api, array_merge([
34
            "client_id" => $this->client_id,
35
            "client_secret" => $this->client_secret
36
        ], $data));
37
    }
38
}
39