1 | <?php |
||||||
2 | |||||||
3 | namespace ByTIC\Payments\Actions\GatewayNotifications; |
||||||
4 | |||||||
5 | use ByTIC\Payments\Models\Transactions\TransactionTrait; |
||||||
6 | use ByTIC\Payments\Utility\PaymentsModels; |
||||||
7 | use Nip\Records\AbstractModels\Record; |
||||||
8 | use Paytic\Omnipay\Common\Models\TokenInterface; |
||||||
9 | |||||||
10 | /** |
||||||
11 | * Class CreateOrUpdateTokenFromResponse |
||||||
12 | * @package ByTIC\Payments\Actions\GatewayNotifications |
||||||
13 | * @internal |
||||||
14 | */ |
||||||
15 | class CreateOrUpdateTokenFromResponse |
||||||
16 | { |
||||||
17 | /** |
||||||
18 | * @param NotificationData $notification |
||||||
19 | * @return TransactionTrait|Record |
||||||
20 | */ |
||||||
21 | public static function handle(NotificationData $notification) |
||||||
22 | { |
||||||
23 | if (!method_exists($notification->response, 'getToken')) { |
||||||
24 | return null; |
||||||
25 | } |
||||||
26 | |||||||
27 | $token = $notification->response->getToken(); |
||||||
28 | if (!($token instanceof TokenInterface)) { |
||||||
29 | return null; |
||||||
30 | } |
||||||
31 | |||||||
32 | if (empty($token->getId())) { |
||||||
33 | return null; |
||||||
34 | } |
||||||
35 | |||||||
36 | $notification->token = PaymentsModels::tokens() |
||||||
37 | ->findOrCreateForMethod($notification->purchase->getPaymentMethod(), $token); |
||||||
38 | $notification->token->populateFromCustomer($notification->purchase->getPurchaseBillingRecord()); |
||||||
0 ignored issues
–
show
|
|||||||
39 | $notification->token->update(); |
||||||
0 ignored issues
–
show
The method
update() does not exist on ByTIC\Payments\Models\Tokens\TokenTrait . Did you maybe mean updatedTimestamps() ?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. ![]() |
|||||||
40 | |||||||
41 | return $notification->token; |
||||||
0 ignored issues
–
show
|
|||||||
42 | } |
||||||
43 | } |
||||||
44 |
This check looks for function or method calls that always return null and whose return value is used.
The method
getObject()
can return nothing but null, so it makes no sense to use the return value.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.