Base   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 36
Duplicated Lines 44.44 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 1
dl 16
loc 36
c 0
b 0
f 0
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A get() 0 8 2
A post() 8 8 2
A put() 8 8 2
A delete() 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 MacsiDigital\Xero\Interfaces;
4
5
use Exception;
6
use MacsiDigital\Xero\Support\Response;
7
8
abstract class Base
9
{
10
    protected $request;
11
12
    public function get($end_point)
13
    {
14
        try {
15
            return new Response($this->request->get($end_point));
16
        } catch (Exception $e) {
17
            return new Response($e->getResponse());
18
        }
19
    }
20
21 View Code Duplication
    public function post($end_point, $fields)
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...
22
    {
23
        try {
24
            return new Response($this->request->post($end_point, $fields));
25
        } catch (Exception $e) {
26
            return new Response($e->getResponse());
27
        }
28
    }
29
30 View Code Duplication
    public function put($end_point, $fields)
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...
31
    {
32
        try {
33
            return new Response($this->request->put($end_point, $fields));
34
        } catch (Exception $e) {
35
            return new Response($e->getResponse());
36
        }
37
    }
38
39
    public function delete($end_point)
40
    {
41
        return new Response($this->request->delete($end_point));
42
    }
43
}
44