Completed
Push — v2.0 ( 499d03...6a6c92 )
by Raza
07:37
created

Reporting   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A listTransactions() 0 8 1
A listBalances() 0 10 2
1
<?php
2
3
namespace Srmklive\PayPal\Traits\PayPalAPI;
4
5
use Carbon\Carbon;
6
7
trait Reporting
8
{
9
    /**
10
     * List all transactions.
11
     *
12
     * @param int $page
13
     * @param int $page_size
14
     *
15
     * @throws \Throwable
16
     *
17
     * @return array|\Psr\Http\Message\StreamInterface|string
18
     *
19
     * @see https://developer.paypal.com/docs/api/transaction-search/v1/#transactions_get
20
     */
21
    public function listTransactions($page = 1, $page_size = 100)
22
    {
23
        $this->apiEndPoint = "v1/reporting/transactions?page={$page}&page_size={$page_size}";
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...
24
        $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...
25
26
        $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...
27
28
        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

28
        return $this->/** @scrutinizer ignore-call */ doPayPalRequest();
Loading history...
29
    }
30
31
    /**
32
     * List available balance.
33
     *
34
     * @param string $date
35
     *
36
     * @throws \Throwable
37
     *
38
     * @return array|\Psr\Http\Message\StreamInterface|string
39
     *
40
     * @see https://developer.paypal.com/docs/api/transaction-search/v1/#balances_get
41
     */
42
    public function listBalances($date = '')
43
    {
44
        $date = empty($date) ? Carbon::now()->toIso8601String() : Carbon::parse($date)->toIso8601String();
45
46
        $this->apiEndPoint = "v1/reporting/balances?currency_code={$this->currency}&as_of_date={$date}";
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...
47
        $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...
48
49
        $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...
50
51
        return $this->doPayPalRequest();
52
    }
53
}
54