Passed
Push — v2.0 ( d916ef...282229 )
by Raza
02:10
created

Disputes   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 64
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 14
c 1
b 0
f 0
dl 0
loc 64
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A updateDispute() 0 10 1
A listDisputes() 0 8 1
A showDisputeDetails() 0 8 1
1
<?php
2
3
namespace Srmklive\PayPal\Traits\PayPalAPI;
4
5
trait Disputes
6
{
7
    /**
8
     * List disputes.
9
     *
10
     * @throws \Throwable
11
     *
12
     * @return array|\Psr\Http\Message\StreamInterface|string
13
     *
14
     * @see https://developer.paypal.com/docs/api/customer-disputes/v1/#disputes_list
15
     */
16
    public function listDisputes()
17
    {
18
        $this->apiEndPoint = "v1/customer/disputes";
1 ignored issue
show
Bug Best Practice introduced by
The property apiEndPoint does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
19
        $this->apiUrl = collect([$this->apiUrl, $this->apiEndPoint])->implode('/');
1 ignored issue
show
Bug Best Practice introduced by
The property apiUrl does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
20
21
        $this->verb = 'get';
1 ignored issue
show
Bug Best Practice introduced by
The property verb does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
22
23
        return $this->doPayPalRequest();
1 ignored issue
show
Bug introduced by
It seems like doPayPalRequest() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

23
        return $this->/** @scrutinizer ignore-call */ doPayPalRequest();
Loading history...
24
    }
25
26
    /**
27
     * Update a dispute.
28
     *
29
     * @param array $data
30
     * @param string $dispute_id
31
     *
32
     * @throws \Throwable
33
     *
34
     * @return array|\Psr\Http\Message\StreamInterface|string
35
     *
36
     * @see https://developer.paypal.com/docs/api/customer-disputes/v1/#disputes_patch
37
     */
38
    public function updateDispute(array $data, $dispute_id)
39
    {
40
        $this->apiEndPoint = "v1/customer/disputes/{$dispute_id}";
1 ignored issue
show
Bug Best Practice introduced by
The property apiEndPoint does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
41
        $this->apiUrl = collect([$this->apiUrl, $this->apiEndPoint])->implode('/');
1 ignored issue
show
Bug Best Practice introduced by
The property apiUrl does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
42
43
        $this->options['json'] = $data;
1 ignored issue
show
Bug Best Practice introduced by
The property options does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
44
45
        $this->verb = 'patch';
1 ignored issue
show
Bug Best Practice introduced by
The property verb does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
46
47
        return $this->doPayPalRequest();
48
    }
49
50
    /**
51
     * Get dispute details.
52
     *
53
     * @param string $dispute_id
54
     *
55
     * @throws \Throwable
56
     *
57
     * @return array|\Psr\Http\Message\StreamInterface|string
58
     *
59
     * @see https://developer.paypal.com/docs/api/customer-disputes/v1/#disputes_get
60
     */
61
    public function showDisputeDetails($dispute_id)
62
    {
63
        $this->apiEndPoint = "v1/customer/disputes/{$dispute_id}";
1 ignored issue
show
Bug Best Practice introduced by
The property apiEndPoint does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
64
        $this->apiUrl = collect([$this->apiUrl, $this->apiEndPoint])->implode('/');
1 ignored issue
show
Bug Best Practice introduced by
The property apiUrl does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
65
66
        $this->verb = 'get';
1 ignored issue
show
Bug Best Practice introduced by
The property verb does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
67
68
        return $this->doPayPalRequest();
69
    }
70
}
71