DekaleeClient   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 112
Duplicated Lines 53.57 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 2
dl 60
loc 112
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A post() 15 15 1
A get() 15 15 1
A put() 15 15 1
A delete() 15 15 1
A getCalls() 0 4 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 Dekalee\MailjetBundle\Client;
4
5
use Mailjet\Client;
6
use Mailjet\Response;
7
8
/**
9
 * Class DekaleeClient
10
 */
11
class DekaleeClient extends Client
12
{
13
    protected $calls = [];
14
15
    /**
16
     * Trigger a POST request
17
     *
18
     * @param array $resource Mailjet Resource/Action pair
19
     * @param array $args     Request arguments
20
     * @param array $options
21
     *
22
     * @return Response
23
     */
24 View Code Duplication
    public function post($resource, array $args = [], array $options = [])
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...
25
    {
26
        $response = parent::post($resource, $args, $options);
27
28
        $this->calls[] = [
29
            'method' => 'POST',
30
            'resource' => $resource,
31
            'args' => $args,
32
            'options' => $options,
33
            'success' => $response->success(),
34
            'response' => $response->getBody(),
35
        ];
36
37
        return $response;
38
    }
39
40
    /**
41
     * Trigger a GET request
42
     *
43
     * @param array $resource Mailjet Resource/Action pair
44
     * @param array $args     Request arguments
45
     * @param array $options
46
     *
47
     * @return Response
48
     */
49 View Code Duplication
    public function get($resource, array $args = [], array $options = [])
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...
50
    {
51
        $response = parent::get($resource, $args, $options);
52
53
        $this->calls[] = [
54
            'method' => 'GET',
55
            'resource' => $resource,
56
            'args' => $args,
57
            'options' => $options,
58
            'success' => $response->success(),
59
            'response' => $response->getBody(),
60
        ];
61
62
        return $response;
63
    }
64
65
    /**
66
     * Trigger a POST request
67
     *
68
     * @param array $resource Mailjet Resource/Action pair
69
     * @param array $args     Request arguments
70
     * @param array $options
71
     *
72
     * @return Response
73
     */
74 View Code Duplication
    public function put($resource, array $args = [], array $options = [])
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...
75
    {
76
        $response = parent::put($resource, $args, $options);
77
78
        $this->calls[] = [
79
            'method' => 'PUT',
80
            'resource' => $resource,
81
            'args' => $args,
82
            'options' => $options,
83
            'success' => $response->success(),
84
            'response' => $response->getBody(),
85
        ];
86
87
        return $response;
88
    }
89
90
    /**
91
     * Trigger a GET request
92
     *
93
     * @param array $resource Mailjet Resource/Action pair
94
     * @param array $args     Request arguments
95
     * @param array $options
96
     *
97
     * @return Response
98
     */
99 View Code Duplication
    public function delete($resource, array $args = [], array $options = [])
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...
100
    {
101
        $response = parent::delete($resource, $args, $options);
102
103
        $this->calls[] = [
104
            'method' => 'DELETE',
105
            'resource' => $resource,
106
            'args' => $args,
107
            'options' => $options,
108
            'success' => $response->success(),
109
            'response' => $response->getBody(),
110
        ];
111
112
        return $response;
113
    }
114
115
    /**
116
     * @return array
117
     */
118
    public function getCalls()
119
    {
120
        return $this->calls;
121
    }
122
}
123