|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* @author @jayS-de <[email protected]> |
|
4
|
|
|
*/ |
|
5
|
|
|
|
|
6
|
|
|
namespace Commercetools\Core\Model\Message; |
|
7
|
|
|
|
|
8
|
|
|
use Commercetools\Core\Model\Common\DateTimeDecorator; |
|
9
|
|
|
use Commercetools\Core\Model\Common\Reference; |
|
10
|
|
|
use Commercetools\Core\Model\Payment\Transaction; |
|
11
|
|
|
use DateTime; |
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* @package Commercetools\Core\Model\Message |
|
15
|
|
|
* @link https://dev.commercetools.com/http-api-projects-messages.html#paymentstatusinterfacecodeset-message |
|
16
|
|
|
* @method string getId() |
|
17
|
|
|
* @method PaymentStatusInterfaceCodeSetMessage setId(string $id = null) |
|
18
|
|
|
* @method int getVersion() |
|
19
|
|
|
* @method PaymentStatusInterfaceCodeSetMessage setVersion(int $version = null) |
|
20
|
|
|
* @method DateTimeDecorator getCreatedAt() |
|
21
|
|
|
* @method PaymentStatusInterfaceCodeSetMessage setCreatedAt(DateTime $createdAt = null) |
|
22
|
|
|
* @method DateTimeDecorator getLastModifiedAt() |
|
23
|
|
|
* @method PaymentStatusInterfaceCodeSetMessage setLastModifiedAt(DateTime $lastModifiedAt = null) |
|
24
|
|
|
* @method int getSequenceNumber() |
|
25
|
|
|
* @method PaymentStatusInterfaceCodeSetMessage setSequenceNumber(int $sequenceNumber = null) |
|
26
|
|
|
* @method Reference getResource() |
|
27
|
|
|
* @method PaymentStatusInterfaceCodeSetMessage setResource(Reference $resource = null) |
|
28
|
|
|
* @method int getResourceVersion() |
|
29
|
|
|
* @method PaymentStatusInterfaceCodeSetMessage setResourceVersion(int $resourceVersion = null) |
|
30
|
|
|
* @method string getType() |
|
31
|
|
|
* @method PaymentStatusInterfaceCodeSetMessage setType(string $type = null) |
|
32
|
|
|
* @method string getInterfaceCode() |
|
33
|
|
|
* @method PaymentStatusInterfaceCodeSetMessage setInterfaceCode(string $interfaceCode = null) |
|
34
|
|
|
*/ |
|
35
|
|
|
class PaymentStatusInterfaceCodeSetMessage extends Message |
|
36
|
|
|
{ |
|
37
|
|
|
const MESSAGE_TYPE = 'PaymentStatusInterfaceCodeSet'; |
|
38
|
|
|
|
|
39
|
|
|
public function fieldDefinitions() |
|
40
|
|
|
{ |
|
41
|
|
|
$definitions = parent::fieldDefinitions(); |
|
42
|
|
|
$definitions['paymentId'] = [static::TYPE => 'string']; |
|
43
|
|
|
$definitions['interfaceCode'] = [static::TYPE => 'string']; |
|
44
|
|
|
|
|
45
|
|
|
return $definitions; |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* @deprecated |
|
50
|
|
|
* @return string |
|
51
|
|
|
*/ |
|
52
|
|
|
public function getPaymentId() |
|
53
|
|
|
{ |
|
54
|
|
|
return parent::getPaymentId(); |
|
|
|
|
|
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* @deprecated |
|
59
|
|
|
* @param string $paymentId |
|
60
|
|
|
* @return static |
|
61
|
|
|
*/ |
|
62
|
|
|
public function setPaymentId($paymentId = null) |
|
63
|
|
|
{ |
|
64
|
|
|
return parent::setPaymentId($paymentId); |
|
|
|
|
|
|
65
|
|
|
} |
|
66
|
|
|
} |
|
67
|
|
|
|
Let’s take a look at an example:
In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different sub-classes of User which does not have a getDisplayName() method, the code will break.
Available Fixes
Change the type-hint for the parameter:
Add an additional type-check:
Add the method to the parent class: