1 | <?php |
||
21 | class MPNS extends PayloadHandler |
||
22 | { |
||
23 | /** |
||
24 | * The maximum size allowed for MPNS message payload is 3K bytes |
||
25 | */ |
||
26 | const PAYLOAD_MAX_LENGTH = 3072; |
||
27 | |||
28 | /** |
||
29 | * Notification delivery interval |
||
30 | * |
||
31 | * @var int |
||
32 | */ |
||
33 | protected $delayInterval; |
||
34 | |||
35 | /** |
||
36 | * @param MessageInterface $message |
||
37 | * @return bool |
||
38 | */ |
||
39 | public function isSupported(MessageInterface $message) |
||
43 | |||
44 | /** |
||
45 | * @return \DOMDocument |
||
46 | */ |
||
47 | public function createPayload() |
||
71 | |||
72 | /** |
||
73 | * @param \DOMDocument $payload |
||
74 | * @return string |
||
75 | */ |
||
76 | public function packPayload($payload) |
||
80 | |||
81 | /** |
||
82 | * @return array |
||
83 | */ |
||
84 | public function getCustomNotificationData() |
||
93 | |||
94 | /** |
||
95 | * @param \DOMDocument $document |
||
96 | * @param \DOMElement $rootElement |
||
97 | * @param MPNSMessage $message |
||
98 | */ |
||
99 | protected function completeDocumentBody( |
||
117 | |||
118 | /** |
||
119 | * @param \DOMDocument $document |
||
120 | * @param \DOMElement $rootElement |
||
121 | * @param MPNSRaw $message |
||
122 | */ |
||
123 | protected function completeRawDocumentBody( |
||
133 | } |
||
134 |
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 implementation 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 interface: