TransactionProxy   A
last analyzed

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\Transaction;
10
use LauLamanApps\eCurring\Resource\Transaction\Event;
11
use LauLamanApps\eCurring\Resource\Transaction\PaymentMethod;
12
use LauLamanApps\eCurring\Resource\Transaction\Status;
13
use LauLamanApps\eCurring\Resource\TransactionInterface;
14
use Money\Money;
15
use Ramsey\Uuid\Uuid;
16
use Ramsey\Uuid\UuidInterface;
17
18
/**
19
 * @method UuidInterface|null getId()
20
 * @method Status|null getStatus()
21
 * @method DateTimeImmutable|null getScheduledOn()
22
 * @method DateTimeImmutable|null getDueDate()
23
 * @method Money getAmount()
24
 * @method DateTimeImmutable|null getCanceledOn()
25
 * @method string|null getWebhookUrl()
26
 * @method PaymentMethod getPaymentMethod()
27
 * @method Event[] getHistory()
28
 */
29
final class TransactionProxy extends AbstractProxy implements TransactionInterface
30
{
31
    /**
32
     * @return Transaction
33
     */
34
    protected function __load(eCurringClientInterface $client, string $id)
35
    {
36
        return $client->getTransaction(Uuid::fromString($id));
0 ignored issues
show
Bug Best Practice introduced by
The expression return $client->getTrans...\Uuid::fromString($id)) returns the type LauLamanApps\eCurring\Resource\Transaction 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