Completed
Push — master ( ef8e02...cd88cd )
by CodexShaper
11:14
created

Refund   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 111
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 2
dl 111
loc 111
ccs 0
cts 17
cp 0
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A all() 6 6 1
A find() 6 6 1
A create() 6 6 1
A delete() 6 6 1
A paginate() 10 10 1
A count() 6 6 1
A save() 6 6 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 Codexshaper\WooCommerce\Models;
4
5
use Codexshaper\WooCommerce\Traits\QueryBuilderTrait;
6
7 View Code Duplication
class Refund extends BaseModel
0 ignored issues
show
Duplication introduced by
This class 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...
8
{
9
    use QueryBuilderTrait;
10
11
    protected $endpoint;
12
13
    /**
14
     * Retrieve all Items.
15
     *
16
     * @param int   $order_id
17
     * @param array $options
18
     *
19
     * @return array
20
     */
21
    protected function all($order_id, $options = [])
22
    {
23
        $this->endpoint = "orders/{$order_id}/refunds";
24
25
        return self::all($options);
0 ignored issues
show
Documentation introduced by
$options is of type array, but the function expects a integer.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
26
    }
27
28
    /**
29
     * Retrieve single Item.
30
     *
31
     * @param int   $order_id
32
     * @param int   $refund_id
33
     * @param array $options
34
     *
35
     * @return object
36
     */
37
    protected function find($order_id, $refund_id, $options = [])
38
    {
39
        $this->endpoint = "orders/{$order_id}/refunds";
40
41
        return self::find($refund_id, $options);
0 ignored issues
show
Documentation introduced by
$options is of type array, but the function expects a integer.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
42
    }
43
44
    /**
45
     * Create new Item.
46
     *
47
     * @param int   $order_id
48
     * @param array $data
49
     *
50
     * @return object
51
     */
52
    protected function create($order_id, $data)
53
    {
54
        $this->endpoint = "orders/{$order_id}/refunds";
55
56
        return self::create($data);
0 ignored issues
show
Bug introduced by
The call to create() misses a required argument $data.

This check looks for function calls that miss required arguments.

Loading history...
Documentation introduced by
$data is of type array, but the function expects a integer.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
57
    }
58
59
    /**
60
     * Destroy Item.
61
     *
62
     * @param int   $order_id
63
     * @param int   $refund_id
64
     * @param array $options
65
     *
66
     * @return object
67
     */
68
    protected function delete($order_id, $refund_id, $options = [])
69
    {
70
        $this->endpoint = "orders/{$order_id}/refunds";
71
72
        return self::delete($refund_id, $options);
0 ignored issues
show
Documentation introduced by
$options is of type array, but the function expects a integer.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
73
    }
74
75
    /**
76
     * Paginate results.
77
     *
78
     * @param int $per_page
79
     * @param int $current_page
80
     *
81
     * @return array
82
     */
83
    protected function paginate(
84
        $order_id, 
85
        $per_page = 10, 
86
        $current_page = 1, 
87
        $options = []
88
    ) {
89
        $this->endpoint = "orders/{$order_id}/refunds";
90
91
        return self::paginate($per_page, $current_page, $options);
0 ignored issues
show
Documentation introduced by
$options is of type array, but the function expects a integer.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
92
    }
93
94
    /**
95
     * Count all results.
96
     *
97
     * @return int
98
     */
99
    protected function count($order_id)
100
    {
101
        $this->endpoint = "orders/{$order_id}/refunds";
102
103
        return self::count();
0 ignored issues
show
Bug introduced by
The call to count() misses a required argument $order_id.

This check looks for function calls that miss required arguments.

Loading history...
104
    }
105
106
    /**
107
     * Store data.
108
     *
109
     * @return array
110
     */
111
    public function save($order_id)
112
    {
113
        $this->endpoint = "orders/{$order_id}/refunds";
114
115
        return self::save();
0 ignored issues
show
Bug introduced by
The call to save() misses a required argument $order_id.

This check looks for function calls that miss required arguments.

Loading history...
116
    }
117
}
118