GET::send()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 2
Bugs 1 Features 0
Metric Value
c 2
b 1
f 0
dl 0
loc 8
ccs 0
cts 7
cp 0
rs 9.4285
cc 2
eloc 6
nc 2
nop 0
crap 6
1
<?php
2
/**
3
 * ©[2016] SugarCRM Inc.  Licensed by SugarCRM under the Apache 2.0 license.
4
 */
5
6
namespace SugarAPI\SDK\Request;
7
8
use SugarAPI\SDK\Request\Abstracts\AbstractRequest;
9
10
class GET extends AbstractRequest {
11
12
    /**
13
     * @inheritdoc
14
     */
15
    protected static $_TYPE = 'GET';
16
17
    /**
18
     * @inheritdoc
19
     */
20
    protected static $_DEFAULT_HEADERS = array(
21
        "Content-Type: application/json"
22
    );
23
24
    /**
25
     * @inheritdoc
26
     *
27
     * Convert Body to Query String
28
     */
29
    public function setBody($body){
30
        $this->body = http_build_query($body);
31
        return $this;
32
    }
33
34
    /**
35
     * @inheritdoc
36
     *
37
     * Configure the URL with Body since Payload is sent via Query String
38
     */
39
    public function send(){
40
        $body = '';
41
        if (!empty($this->body)){
42
            $body = "?".$this->body;
43
        }
44
        $this->setURL($this->url.$body);
45
        return parent::send();
46
    }
47
48
}