ApiKeyNotSetException::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 19
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 15
nc 1
nop 8
dl 0
loc 19
ccs 5
cts 5
cp 1
crap 1
rs 9.4285
c 0
b 0
f 0

How to fix   Many Parameters   

Many Parameters

Methods with many parameters are not only hard to understand, but their parameters also often become inconsistent when you need more, or different data.

There are several approaches to avoid long parameter lists:

1
<?php namespace Arcanedev\Stripe\Exceptions;
2
3
/**
4
 * Class     ApiKeyNotSetException
5
 *
6
 * @package  Arcanedev\Stripe\Exceptions
7
 * @author   ARCANEDEV <[email protected]>
8
 */
9
class ApiKeyNotSetException extends AuthenticationException
10
{
11
    /* ------------------------------------------------------------------------------------------------
12
     |  Constructor
13
     | ------------------------------------------------------------------------------------------------
14
     */
15
    /**
16
     * API Key Not Set Constructor.
17
     *
18
     * @param  string       $message
19
     * @param  int          $code
20
     * @param  string|null  $type
21
     * @param  string|null  $stripeCode
22
     * @param  string|null  $httpBody
23
     * @param  array        $jsonBody
24
     * @param  array        $params
25
     * @param  array        $headers
26
     */
27 4
    public function __construct(
28
        $message,
29
        $code = 500,
30
        $type = 'api_error',
31
        $stripeCode = null,
32
        $httpBody = null,
33
        $jsonBody = [],
34
        $params = [],
35
        $headers = []
36
    ) {
37
        $message = 'No API key provided.  (HINT: set your API key using '
38
            . '"Stripe::setApiKey(<API-KEY>)".  You can generate API keys from '
39
            . 'the Stripe web interface.  See https://stripe.com/api for '
40 4
            . 'details, or email [email protected] if you have any questions.';
41
42 4
        parent::__construct(
43 4
            $message, $code, $type, $stripeCode, $httpBody, $jsonBody, $params, $headers
44
        );
45 4
    }
46
}
47