PostJson::__construct()   A
last analyzed

Complexity

Conditions 3
Paths 4

Size

Total Lines 15
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 7
c 1
b 0
f 0
nc 4
nop 3
dl 0
loc 15
rs 10
1
<?php
2
namespace CodeCloud\Bundle\ShopifyBundle\Api\Request;
3
4
use GuzzleHttp\Psr7\Request;
5
6
class PostJson extends Request
7
{
8
    /**
9
     * @param string $url
10
     * @param array|string $postData
11
     * @param array $params
12
     */
13
    public function __construct($url, $postData = null, array $params = array())
14
    {
15
        if ($postData !== null) {
16
            $postData = \GuzzleHttp\json_encode($postData, JSON_PRETTY_PRINT);
17
        }
18
19
        if (!empty($params)) {
20
            $url .= '?'.http_build_query($params);
21
        }
22
23
        $headers = [
24
            'Content-Type' => 'application/json',
25
        ];
26
27
        parent::__construct('POST', $url, $headers, $postData);
28
    }
29
}
30