Completed
Push — master ( f6940b...5339e4 )
by Tobias
01:46
created

Custom   A

Complexity

Total Complexity 12

Size/Duplication

Total Lines 62
Duplicated Lines 87.1 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 12
lcom 1
cbo 2
dl 54
loc 62
ccs 0
cts 48
cp 0
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A get() 9 9 2
A post() 9 9 2
A postRaw() 9 9 2
A put() 9 9 2
A patch() 9 9 2
A delete() 9 9 2

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
declare(strict_types=1);
4
5
/*
6
 * This software may be modified and distributed under the terms
7
 * of the MIT license. See the LICENSE file for details.
8
 */
9
10
namespace FAPI\Sylius\Api;
11
12
/**
13
 * @author Tobias Nyholm <[email protected]>
14
 */
15
final class Custom extends HttpApi
16
{
17 View Code Duplication
    public function get(string $path, array $params = [], array $requestHeaders = [], string $class = '')
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...
18
    {
19
        $response = parent::httpGet($path, $params, $requestHeaders);
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (httpGet() instead of get()). Are you sure this is correct? If so, you might want to change this to $this->httpGet().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
20
        if (!$this->hydrator) {
21
            return $response;
22
        }
23
24
        return $this->hydrator->hydrate($response, $class);
25
    }
26
27 View Code Duplication
    public function post(string $path, array $params = [], array $requestHeaders = [], string $class = '')
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...
28
    {
29
        $response = parent::httpPost($path, $params, $requestHeaders);
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (httpPost() instead of post()). Are you sure this is correct? If so, you might want to change this to $this->httpPost().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
30
        if (!$this->hydrator) {
31
            return $response;
32
        }
33
34
        return $this->hydrator->hydrate($response, $class);
35
    }
36
37 View Code Duplication
    public function postRaw(string $path, $body, array $requestHeaders = [], string $class = '')
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...
38
    {
39
        $response = parent::httpPostRaw($path, $body, $requestHeaders);
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (httpPostRaw() instead of postRaw()). Are you sure this is correct? If so, you might want to change this to $this->httpPostRaw().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
40
        if (!$this->hydrator) {
41
            return $response;
42
        }
43
44
        return $this->hydrator->hydrate($response, $class);
45
    }
46
47 View Code Duplication
    public function put(string $path, array $params = [], array $requestHeaders = [], string $class = '')
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...
48
    {
49
        $response = parent::httpPut($path, $params, $requestHeaders);
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (httpPut() instead of put()). Are you sure this is correct? If so, you might want to change this to $this->httpPut().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
50
        if (!$this->hydrator) {
51
            return $response;
52
        }
53
54
        return $this->hydrator->hydrate($response, $class);
55
    }
56
57 View Code Duplication
    public function patch(string $path, array $params = [], array $requestHeaders = [], string $class = '')
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...
58
    {
59
        $response = parent::httpPatch($path, $params, $requestHeaders);
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (httpPatch() instead of patch()). Are you sure this is correct? If so, you might want to change this to $this->httpPatch().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
60
        if (!$this->hydrator) {
61
            return $response;
62
        }
63
64
        return $this->hydrator->hydrate($response, $class);
65
    }
66
67 View Code Duplication
    public function delete(string $path, array $params = [], array $requestHeaders = [], string $class = '')
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...
68
    {
69
        $response = parent::httpDelete($path, $params, $requestHeaders);
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (httpDelete() instead of delete()). Are you sure this is correct? If so, you might want to change this to $this->httpDelete().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
70
        if (!$this->hydrator) {
71
            return $response;
72
        }
73
74
        return $this->hydrator->hydrate($response, $class);
75
    }
76
}
77