wp-pay-gateways /
mollie
| 1 | <?php |
||
| 2 | /** |
||
| 3 | * Payment Details |
||
| 4 | * |
||
| 5 | * @author Pronamic <[email protected]> |
||
| 6 | * @copyright 2005-2022 Pronamic |
||
| 7 | * @license GPL-3.0-or-later |
||
| 8 | * @package Pronamic\WordPress\Pay\Gateways\Mollie |
||
| 9 | */ |
||
| 10 | |||
| 11 | namespace Pronamic\WordPress\Pay\Gateways\Mollie; |
||
| 12 | |||
| 13 | /** |
||
| 14 | * Payment Details |
||
| 15 | * |
||
| 16 | * @author Remco Tolsma |
||
| 17 | * @version 2.1.0 |
||
| 18 | * @since 2.1.0 |
||
| 19 | */ |
||
| 20 | class PaymentDetails { |
||
| 21 | /** |
||
| 22 | * Create payment detailsfrom JSON. |
||
| 23 | * |
||
| 24 | * @link https://docs.mollie.com/reference/v2/payments-api/get-payment |
||
| 25 | * @param string $method Payment method. |
||
| 26 | * @param object|null $json JSON object. |
||
| 27 | * @return PaymentDetails|null |
||
| 28 | * @throws \JsonSchema\Exception\ValidationException Throws JSON schema validation exception when JSON is invalid. |
||
| 29 | */ |
||
| 30 | public static function from_json( $method, $json ) { |
||
|
0 ignored issues
–
show
|
|||
| 31 | if ( null === $json ) { |
||
| 32 | return null; |
||
| 33 | } |
||
| 34 | |||
| 35 | $validator = new \JsonSchema\Validator(); |
||
| 36 | |||
| 37 | $validator->validate( |
||
| 38 | $json, |
||
| 39 | (object) array( |
||
| 40 | '$ref' => 'file://' . realpath( __DIR__ . '/../json-schemas/payment-details.json' ), |
||
| 41 | ), |
||
| 42 | \JsonSchema\Constraints\Constraint::CHECK_MODE_EXCEPTIONS |
||
| 43 | ); |
||
| 44 | |||
| 45 | $details = new PaymentDetails(); |
||
| 46 | |||
| 47 | foreach ( $json as $key => $value ) { |
||
| 48 | $details->{$key} = $value; |
||
| 49 | } |
||
| 50 | |||
| 51 | return $details; |
||
| 52 | } |
||
| 53 | } |
||
| 54 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.