PatchRequestBuilder   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A build() 0 15 4
1
<?php
2
3
namespace Knp\FriendlyContexts\Builder;
4
5
class PatchRequestBuilder extends AbstractRequestBuilder
6
{
7
    public function build($uri = null, array $queries = null, array $headers = null, array $postBody = null, $body = null, array $options = [])
8
    {
9
        parent::build($uri, $queries, $headers, $postBody, $body, $options);
10
11
        if (is_array($body)) {
12
            // format the body request to a corect x-www-form-urlencoded
13
            $body = $this->formatQueryString($body);
14
            // Set a defaut form content type
15
            $headers = $headers ?: [];
16
            $headers['Content-Type'] = 'application/x-www-form-urlencoded';
17
        }
18
19
        $resource = $queries ? sprintf('%s?%s', $uri, $this->formatQueryString($queries)) : $uri;
20
21
        return $this->getClient()->patch($resource, $headers, $body, $options);
22
    }
23
}
24