Completed
Pull Request — master (#24)
by
unknown
02:00
created

GenericApi   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 34
Duplicated Lines 88.24 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 3
dl 30
loc 34
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 16 16 1
A update() 14 14 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace Sylius\Api\Checkout;
4
5
use Sylius\Api\GenericApi as BaseApi;
6
7
class GenericApi extends BaseApi
8
{
9 View Code Duplication
    public function create(array $body, array $uriParameters = [], array $files = [])
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...
10
    {
11
        $response = $this
12
            ->getClient()
13
            ->put(
14
                $this->getUri(
15
                    $uriParameters,
16
                    $body,
0 ignored issues
show
Unused Code introduced by
The call to GenericApi::getUri() has too many arguments starting with $body.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
17
                    $files
18
                ),
19
                $body
20
            )
21
        ;
22
23
        return $response->getStatusCode() === 204;
24
    }
25
26 View Code Duplication
    public function update($id, array $body, array $uriParameters = [], array $files = [])
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...
27
    {
28
        $uri = sprintf('%s%s', $this->getUri($uriParameters), $id);
29
30
        $response = $this
31
            ->getClient()
32
            ->put(
33
                $uri,
34
                $body
35
            )
36
        ;
37
38
        return $response->getStatusCode() === 204;
39
    }
40
}
41