Code Duplication    Length = 19-22 lines in 3 locations

src/Knp/FriendlyContexts/Builder/DeleteRequestBuilder.php 1 location

@@ 5-26 (lines=22) @@
2
3
namespace Knp\FriendlyContexts\Builder;
4
5
class DeleteRequestBuilder 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 ?
20
            sprintf('%s?%s', $uri, $this->formatQueryString($queries)) :
21
            $uri
22
        ;
23
24
        return $this->getClient()->delete($resource, $headers, $body, $options);
25
    }
26
}
27

src/Knp/FriendlyContexts/Builder/PatchRequestBuilder.php 1 location

@@ 5-23 (lines=19) @@
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

src/Knp/FriendlyContexts/Builder/PutRequestBuilder.php 1 location

@@ 5-23 (lines=19) @@
2
3
namespace Knp\FriendlyContexts\Builder;
4
5
class PutRequestBuilder 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()->put($resource, $headers, $body, $options);
22
    }
23
}
24