Conditions | 1 |
Paths | 1 |
Total Lines | 23 |
Code Lines | 9 |
Lines | 23 |
Ratio | 100 % |
Tests | 9 |
CRAP Score | 1 |
Changes | 0 |
1 | <?php |
||
40 | 1 | View Code Duplication | public function create(array $body) |
|
|||
41 | { |
||
42 | // keys that are mandatory for this request |
||
43 | 1 | $needKeys = ['Contact_Email', 'Contact_Phone']; |
|
44 | |||
45 | // if the body doesn't have needed fields, throw an exception |
||
46 | 1 | $this->validateHasKeys($body, $needKeys); |
|
47 | |||
48 | // make the URL for this request |
||
49 | 1 | $url = $this->getBaseUrl(); |
|
50 | |||
51 | // get the headers for this request |
||
52 | 1 | $headers = $this->headers->make('POST', $url, $body); |
|
53 | |||
54 | // get the response |
||
55 | 1 | $response = $this->client->post($url, [ |
|
56 | 1 | 'headers' => $headers, |
|
57 | 1 | 'json' => $body, |
|
58 | ]); |
||
59 | |||
60 | // return the response |
||
61 | 1 | return $response; |
|
62 | } |
||
63 | } |
||
64 |
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.