Test Failed
Pull Request — master (#31)
by
unknown
02:31
created

setSubscriptionRequest()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 5
ccs 0
cts 3
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 2
1
<?php
2
3
namespace CommerceGuys\AuthNet;
4
5
use GuzzleHttp\Client;
6
use CommerceGuys\AuthNet\DataTypes\SubscriptionRequest;
7
use CommerceGuys\AuthNet\Request\RequestInterface;
8
9
/**
10
 * Use this method to create subscriptions using Automated Recurring Billing.
11
 *
12
 * @link https://developer.authorize.net/api/reference/#recurring-billing
13
 */
14
class ARBCreateSubscriptionRequest extends BaseApiRequest
15
{
16
    protected $subscriptionRequest;
17
18
    public function __construct(
19
        Configuration $configuration,
20
        Client $client,
21
        Subscription $subscription = null
22
    ) {
23
        parent::__construct($configuration, $client);
24
        $this->subscriptionRequest = $subscription;
25
    }
26
27
    /**
28
     * @param \CommerceGuys\AuthNet\DataTypes\SubscriptionRequest $subscriptionRequest
29
     * @return $this
30
     */
31
    public function setSubscriptionRequest(SubscriptionRequest $subscriptionRequest)
0 ignored issues
show
Unused Code introduced by
The parameter $subscriptionRequest is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
32
    {
33
        $this->subscriptionRequest = $subscription;
0 ignored issues
show
Bug introduced by
The variable $subscription does not exist. Did you mean $subscriptionRequest?

This check looks for variables that are accessed but have not been defined. It raises an issue if it finds another variable that has a similar name.

The variable may have been renamed without also renaming all references.

Loading history...
34
        return $this;
35
    }
36
37
    protected function attachData(RequestInterface $request)
38
    {
39
        $request->addDataType($this->subscriptionRequest);
0 ignored issues
show
Bug introduced by
It seems like $this->subscriptionRequest can also be of type null; however, CommerceGuys\AuthNet\Req...nterface::addDataType() does only seem to accept object<CommerceGuys\Auth...ypes\DataTypeInterface>, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
40
    }
41
}
42