CheckoutService::getCheckoutUrl()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 10
Ratio 100 %

Importance

Changes 0
Metric Value
cc 1
eloc 6
nc 1
nop 2
dl 10
loc 10
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
/*
4
 * This file is part of PHP CS Fixer.
5
 *
6
 * (c) Fabien Potencier <[email protected]>
7
 *     Dariusz Rumiński <[email protected]>
8
 *
9
 * This source file is subject to the MIT license that is bundled
10
 * with this source code in the file LICENSE.
11
 */
12
13
namespace Etrias\PaazlConnector\Services;
14
15
use Etrias\PaazlConnector\Client\PaazlClientInterface;
16
use Etrias\PaazlConnector\SoapTypes\BaseCheckoutRequestType;
17
18
class CheckoutService implements CheckoutServiceInterface
19
{
20
    /**
21
     * @var PaazlClientInterface
22
     */
23
    protected $client;
24
    /**
25
     * @var SecurityServiceInterface
26
     */
27
    protected $security;
28
29
    /**
30
     * DocumentService constructor.
31
     *
32
     * @param PaazlClientInterface     $client
33
     * @param SecurityServiceInterface $security
34
     */
35
    public function __construct(PaazlClientInterface $client, SecurityServiceInterface $security)
36
    {
37
        $this->security = $security;
38
        $this->client = $client;
39
    }
40
41
    /**
42
     * {@inheritdoc}
43
     */
44 View Code Duplication
    public function getCheckoutUrl($orderReference, $targetWebShop = null)
1 ignored issue
show
Duplication introduced by
This method 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...
45
    {
46
        $request = new BaseCheckoutRequestType(
47
            $this->security->getHash($orderReference),
48
            $this->client->getWebShopId(),
49
            $targetWebShop,
50
            $orderReference
51
        );
52
53
        return $this->client->checkout($request);
54
    }
55
56
    /**
57
     * {@inheritdoc}
58
     */
59 View Code Duplication
    public function getCheckoutStatus($orderReference, $targetWebShop = null)
1 ignored issue
show
Duplication introduced by
This method 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...
60
    {
61
        $request = new BaseCheckoutRequestType(
62
            $this->security->getHash($orderReference),
63
            $this->client->getWebShopId(),
64
            $targetWebShop,
65
            $orderReference
66
        );
67
68
        return $this->client->checkoutStatus($request);
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->client->checkoutStatus($request) returns the type Etrias\PaazlConnector\SoapTypes\CheckoutResponse which is incompatible with the return type mandated by Etrias\PaazlConnector\Se...ce::getCheckoutStatus() of Etrias\PaazlConnector\So...\CheckoutStatusResponse.

In the issue above, the returned value is violating the contract defined by the mentioned interface.

Let's take a look at an example:

interface HasName {
    /** @return string */
    public function getName();
}

class Name {
    public $name;
}

class User implements HasName {
    /** @return string|Name */
    public function getName() {
        return new Name('foo'); // This is a violation of the ``HasName`` interface
                                // which only allows a string value to be returned.
    }
}
Loading history...
69
    }
70
}
71