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

Card   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 24
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 6

Importance

Changes 0
Metric Value
dl 24
loc 24
rs 10
c 0
b 0
f 0
wmc 1
lcom 0
cbo 6

1 Method

Rating   Name   Duplication   Size   Complexity  
A details() 8 8 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\Issuing;
4
5
/**
6
 * Class Card
7
 *
8
 * @property string $id
9
 * @property string $object
10
 * @property mixed $authorization_controls
11
 * @property mixed $billing
12
 * @property string $brand
13
 * @property Cardholder $cardholder
14
 * @property int $created
15
 * @property string $currency
16
 * @property int $exp_month
17
 * @property int $exp_year
18
 * @property string $last4
19
 * @property bool $livemode
20
 * @property \Stripe\StripeObject $metadata
21
 * @property string $name
22
 * @property mixed $shipping
23
 * @property string $status
24
 * @property string $type
25
 *
26
 * @package Stripe\Issuing
27
 */
28 View Code Duplication
class Card extends \Stripe\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...
29
{
30
    const OBJECT_NAME = "issuing.card";
31
32
    use \Stripe\ApiOperations\All;
33
    use \Stripe\ApiOperations\Create;
34
    use \Stripe\ApiOperations\Retrieve;
35
    use \Stripe\ApiOperations\Update;
36
37
    /**
38
     * @param array|null $params
39
     * @param array|string|null $options
40
     *
41
     * @return CardDetails The card details associated with that issuing card.
42
     */
43
    public function details($params = null, $options = null)
44
    {
45
        $url = $this->instanceUrl() . '/details';
46
        list($response, $opts) = $this->_request('get', $url, $params, $options);
0 ignored issues
show
Bug introduced by
It seems like $params can also be of type null; however, Stripe\ApiOperations\Request::_request() does only seem to accept array, 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...
47
        $obj = \Stripe\Util\Util::convertToStripeObject($response, $opts);
48
        $obj->setLastResponse($response);
49
        return $obj;
50
    }
51
}
52