Test Failed
Push — master ( 3dd85e...34f16b )
by Devin
04:34 queued 10s
created

Capability   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 66
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 5

Importance

Changes 0
Metric Value
dl 66
loc 66
rs 10
c 0
b 0
f 0
wmc 4
lcom 0
cbo 5

3 Methods

Rating   Name   Duplication   Size   Complexity  
A instanceUrl() 19 19 2
A retrieve() 6 6 1
A update() 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 Stripe;
4
5
/**
6
 * Class Capability
7
 *
8
 * @package Stripe
9
 *
10
 * @property string $id
11
 * @property string $object
12
 * @property string $account
13
 * @property bool $requested
14
 * @property int $requested_at
15
 * @property mixed $requirements
16
 * @property string $status
17
 */
18 View Code Duplication
class Capability extends ApiResource
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...
19
{
20
21
    const OBJECT_NAME = "capability";
22
23
    use ApiOperations\Update;
24
25
    /**
26
     * Possible string representations of a capability's status.
27
     * @link https://stripe.com/docs/api/capabilities/object#capability_object-status
28
     */
29
    const STATUS_ACTIVE      = 'active';
30
    const STATUS_INACTIVE    = 'inactive';
31
    const STATUS_PENDING     = 'pending';
32
    const STATUS_UNREQUESTED = 'unrequested';
33
34
    /**
35
     * @return string The API URL for this Stripe account reversal.
36
     */
37
    public function instanceUrl()
38
    {
39
        $id = $this['id'];
40
        $account = $this['account'];
41
        if (!$id) {
42
            throw new Error\InvalidRequest(
43
                "Could not determine which URL to request: " .
44
                "class instance has invalid ID: $id",
45
                null
46
            );
47
        }
48
        $id = Util\Util::utf8($id);
49
        $account = Util\Util::utf8($account);
50
51
        $base = Account::classUrl();
52
        $accountExtn = urlencode($account);
53
        $extn = urlencode($id);
54
        return "$base/$accountExtn/capabilities/$extn";
55
    }
56
57
    /**
58
     * @param array|string $_id
59
     * @param array|string|null $_opts
60
     *
61
     * @throws \Stripe\Error\InvalidRequest
62
     */
63
    public static function retrieve($_id, $_opts = null)
0 ignored issues
show
Unused Code introduced by
The parameter $_id 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...
Unused Code introduced by
The parameter $_opts 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...
64
    {
65
        $msg = "Capabilities cannot be accessed without an account ID. " .
66
               "Retrieve a Capability using \$account->retrieveCapability('acap_123') instead.";
67
        throw new Error\InvalidRequest($msg, null);
68
    }
69
70
    /**
71
     * @param string $_id
72
     * @param array|null $_params
73
     * @param array|string|null $_options
74
     *
75
     * @throws \Stripe\Error\InvalidRequest
76
     */
77
    public static function update($_id, $_params = null, $_options = null)
0 ignored issues
show
Unused Code introduced by
The parameter $_id 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...
Unused Code introduced by
The parameter $_params 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...
Unused Code introduced by
The parameter $_options 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...
78
    {
79
        $msg = "Capabilities cannot be accessed without an account ID. " .
80
               "Update a Capability using \$account->updateCapability('acap_123') instead.";
81
        throw new Error\InvalidRequest($msg, null);
82
    }
83
}
84