GET::setBody()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 4
Bugs 1 Features 0
Metric Value
c 4
b 1
f 0
dl 0
loc 4
ccs 0
cts 3
cp 0
rs 10
cc 1
eloc 3
nc 1
nop 1
crap 2
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
}