Issues (453)

src/Services/CheckoutService.php (1 issue)

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)
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)
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