GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — 1.x ( f2247a...73fe3f )
by Jakub
04:00
created

InitiatePayment   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 50
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 4
dl 50
loc 50
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 10 10 1
A call() 15 15 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 zaporylie\Vipps\Resource\Payment;
4
5
use zaporylie\Vipps\Model\Payment\RequestInitiatePayment;
6
use zaporylie\Vipps\Model\Payment\ResponseInitiatePayment;
7
use zaporylie\Vipps\Resource\HttpMethod;
8
use zaporylie\Vipps\VippsInterface;
9
10
/**
11
 * Class InitiatePayment
12
 *
13
 * @package Vipps\Resource\Payment
14
 */
15 View Code Duplication
class InitiatePayment extends PaymentResourceBase
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...
16
{
17
18
    /**
19
     * @var \zaporylie\Vipps\Resource\HttpMethod
20
     */
21
    protected $method = HttpMethod::POST;
22
23
    /**
24
     * @var string
25
     */
26
    protected $path = '/Ecomm/v1/payments';
27
28
    /**
29
     * InitiatePayment constructor.
30
     *
31
     * @param \zaporylie\Vipps\VippsInterface $vipps
32
     * @param string $subscription_key
33
     * @param \zaporylie\Vipps\Model\Payment\RequestInitiatePayment $requestObject
34
     */
35
    public function __construct(VippsInterface $vipps, $subscription_key, RequestInitiatePayment $requestObject)
36
    {
37
        parent::__construct($vipps, $subscription_key);
38
        $this->body = $this
39
            ->getSerializer()
40
            ->serialize(
41
                $requestObject,
42
                'json'
43
            );
44
    }
45
46
    /**
47
     * @return \zaporylie\Vipps\Model\Payment\ResponseInitiatePayment
48
     */
49
    public function call()
50
    {
51
        $response = $this->makeCall();
52
        $body = $response->getBody()->getContents();
53
        /** @var \zaporylie\Vipps\Model\Payment\ResponseInitiatePayment $responseObject */
54
        $responseObject = $this
55
            ->getSerializer()
56
            ->deserialize(
57
                $body,
58
                ResponseInitiatePayment::class,
59
                'json'
60
            );
61
62
        return $responseObject;
63
    }
64
}
65