BillingAgreementService::deleteBillingAgreement()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 3
c 1
b 0
f 1
nc 1
nop 1
dl 0
loc 5
rs 10
1
<?php
2
3
namespace App\Service\Paypal;
4
5
/**
6
 * Class BillingAgreementService
7
 * @package App\Service\Paypal
8
 */
9
class BillingAgreementService extends IdentityService
10
{
11
    /**
12
     * @param $requestBody
13
     * @param string $url
14
     * @param array $inputHeaders
15
     * @param string $verb
16
     * @return array|string|null
17
     */
18
    public function doPaypalApiCall($requestBody, string $url, array $inputHeaders = [], string $verb = 'POST')
19
    {
20
        $accessToken = $this->getAccessToken();
21
        return $this->paypalApiCall($accessToken, $requestBody, $url, $inputHeaders, $verb);
0 ignored issues
show
Bug introduced by
It seems like $accessToken can also be of type null; however, parameter $accessToken of App\Service\Paypal\Abstr...ervice::paypalApiCall() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

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

21
        return $this->paypalApiCall(/** @scrutinizer ignore-type */ $accessToken, $requestBody, $url, $inputHeaders, $verb);
Loading history...
22
    }
23
24
    /**
25
     * @param $requestBody
26
     * @return bool|string|null
27
     */
28
    public function createBillingAgreementToken($requestBody)
29
    {
30
        return $this->doPaypalApiCall(
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->doPaypalAp...ents/agreement-tokens') also could return the type array<string,mixed|string|true> which is incompatible with the documented return type boolean|null|string.
Loading history...
31
            $requestBody,
32
            'https://api.sandbox.paypal.com/v1/billing-agreements/agreement-tokens'
33
        );
34
    }
35
36
    /**
37
     * @param $requestBody
38
     * @return bool|string|null
39
     */
40
    public function createBillingAgreement($requestBody)
41
    {
42
        return $this->doPaypalApiCall(
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->doPaypalAp...agreements/agreements') also could return the type array<string,mixed|string|true> which is incompatible with the documented return type boolean|null|string.
Loading history...
43
            $requestBody,
44
            'https://api.sandbox.paypal.com/v1/billing-agreements/agreements'
45
        );
46
    }
47
48
    /**
49
     * @param $requestBody
50
     * @param string $fraudnetSession
51
     * @return bool|string|null
52
     */
53
    public function createReferenceTransaction($requestBody, string $fraudnetSession)
54
    {
55
        return $this->doPaypalApiCall(
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->doPaypalAp... ' . $fraudnetSession)) also could return the type array<string,mixed|string|true> which is incompatible with the documented return type boolean|null|string.
Loading history...
56
            $requestBody,
57
            'https://api.sandbox.paypal.com/v1/payments/payment',
58
            ['PAYPAL-CLIENT-METADATA-ID: '.$fraudnetSession]
59
        );
60
    }
61
62
    /**
63
     * @param string $billingAgreementId
64
     * @return bool|string|null
65
     */
66
    public function deleteBillingAgreement(string $billingAgreementId)
67
    {
68
        return $this->doPaypalApiCall(
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->doPaypalAp...greementId . '/cancel') also could return the type array<string,mixed|string|true> which is incompatible with the documented return type boolean|null|string.
Loading history...
69
            null,
70
            'https://api.sandbox.paypal.com/v1/billing-agreements/agreements/' . $billingAgreementId . '/cancel'
71
        );
72
    }
73
}
74