Passed
Push — master ( 5d017b...8e35dd )
by Laurens
05:45 queued 12s
created

ProductProxy   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 8
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 1
eloc 2
dl 0
loc 8
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __load() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace LauLamanApps\eCurring\Resource\Proxy;
6
7
use DateTimeImmutable;
8
use LauLamanApps\eCurring\eCurringClientInterface;
9
use LauLamanApps\eCurring\Resource\Product;
10
use LauLamanApps\eCurring\Resource\Product\AuthenticationMethod;
11
use LauLamanApps\eCurring\Resource\Product\Status;
12
use LauLamanApps\eCurring\Resource\ProductInterface;
13
use LauLamanApps\eCurring\Resource\SubscriptionInterface;
14
15
/**
16
 * @method int getId()
17
 * @method string getName()
18
 * @method string getDescription()
19
 * @method DateTimeImmutable getStartDate()
20
 * @method Status getStatus()
21
 * @method AuthenticationMethod getMandateAuthenticationMethod()
22
 * @method bool isSendInvoice()
23
 * @method int getStornoRetries()
24
 * @method string|null getTerms()
25
 * @method SubscriptionInterface[] getSubscriptions()
26
 * @method DateTimeImmutable getCreatedAt()
27
 * @method DateTimeImmutable getUpdatedAt()
28
 */
29
final class ProductProxy extends AbstractProxy implements ProductInterface
30
{
31
    /**
32
     * @return Product
33
     */
34
    protected function __load(eCurringClientInterface $client, string $id)
35
    {
36
        return $client->getProduct($id);
0 ignored issues
show
Bug Best Practice introduced by
The expression return $client->getProduct($id) returns the type LauLamanApps\eCurring\Resource\Product which is incompatible with the return type mandated by LauLamanApps\eCurring\Re...AbstractProxy::__load() of LauLamanApps\eCurring\Resource\Subscription.

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...
37
    }
38
}
39