PostJson   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 22
rs 10
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 15 3
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