Completed
Push — master ( bc1208...c4da36 )
by Neomerx
05:13
created

HttpCallsTrait::delete()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 2
cts 2
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 7
nc 1
nop 4
crap 1
1
<?php namespace Limoncello\Testing;
2
3
/**
4
 * Copyright 2015-2017 [email protected]
5
 *
6
 * Licensed under the Apache License, Version 2.0 (the "License");
7
 * you may not use this file except in compliance with the License.
8
 * You may obtain a copy of the License at
9
 *
10
 * http://www.apache.org/licenses/LICENSE-2.0
11
 *
12
 * Unless required by applicable law or agreed to in writing, software
13
 * distributed under the License is distributed on an "AS IS" BASIS,
14
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
 * See the License for the specific language governing permissions and
16
 * limitations under the License.
17
 */
18
19
use Psr\Http\Message\ResponseInterface;
20
21
/** @noinspection PhpTooManyParametersInspection
22
 * @package Limoncello\Testing
23
 *
24
 * @method ResponseInterface call(string $method, string $uri, array $queryParams = [], array $parsedBody = [], array $headers = [], array $cookies = [], array $files = [], array $server = [], string $messageBody = 'php://input')
25
 */
26
trait HttpCallsTrait
27
{
28
    /**
29
     * @param string $uri
30
     * @param array  $queryParams
31
     * @param array  $headers
32
     * @param array  $cookies
33
     *
34
     * @return ResponseInterface
35
     */
36 1
    protected function get(
37
        string $uri,
38
        array $queryParams = [],
39
        array $headers = [],
40
        array $cookies = []
41
    ): ResponseInterface {
42 1
        return $this->call('GET', $uri, $queryParams, [], $headers, $cookies);
43
    }
44
45
    /**
46
     * @param string $uri
47
     * @param array  $data
48
     * @param array  $headers
49
     * @param array  $cookies
50
     *
51
     * @return ResponseInterface
52
     */
53 1 View Code Duplication
    protected function post(
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
54
        string $uri,
55
        array $data = [],
56
        array $headers = [],
57
        array $cookies = []
58
    ): ResponseInterface {
59 1
        $headers['CONTENT_TYPE'] = 'application/x-www-form-urlencoded';
60
61 1
        return $this->call('POST', $uri, [], $data, $headers, $cookies);
62
    }
63
64
    /**
65
     * @param string $uri
66
     * @param array  $data
67
     * @param array  $headers
68
     * @param array  $cookies
69
     *
70
     * @return ResponseInterface
71
     */
72 1 View Code Duplication
    protected function put(
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
73
        string $uri,
74
        array $data = [],
75
        array $headers = [],
76
        array $cookies = []
77
    ): ResponseInterface {
78 1
        $headers['CONTENT_TYPE'] = 'application/x-www-form-urlencoded';
79
80 1
        return $this->call('PUT', $uri, [], $data, $headers, $cookies);
81
    }
82
83
    /**
84
     * @param string $uri
85
     * @param array  $data
86
     * @param array  $headers
87
     * @param array  $cookies
88
     *
89
     * @return ResponseInterface
90
     */
91 1 View Code Duplication
    protected function patch(
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
92
        string $uri,
93
        array $data = [],
94
        array $headers = [],
95
        array $cookies = []
96
    ): ResponseInterface {
97 1
        $headers['CONTENT_TYPE'] = 'application/x-www-form-urlencoded';
98
99 1
        return $this->call('PATCH', $uri, [], $data, $headers, $cookies);
100
    }
101
102
    /**
103
     * @param string $uri
104
     * @param array  $data
105
     * @param array  $headers
106
     * @param array  $cookies
107
     *
108
     * @return ResponseInterface
109
     */
110 1
    protected function delete(
111
        string $uri,
112
        array $data = [],
113
        array $headers = [],
114
        array $cookies = []
115
    ): ResponseInterface {
116 1
        return $this->call('DELETE', $uri, [], $data, $headers, $cookies);
117
    }
118
}
119