diff --git a/composer.json b/composer.json index 852ea88..3feec0b 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,6 @@ "require": { "php": ">=8.0", "ext-json": "*", - "justinrainbow/json-schema": "^5.2", "pronamic/wp-http": "^1.1", "pronamic/wp-number": "^1.1", "pronamic/wp-money": "^2.0" diff --git a/src/Amount.php b/src/Amount.php index 02a13ca..f6e2e78 100644 --- a/src/Amount.php +++ b/src/Amount.php @@ -13,8 +13,6 @@ use InvalidArgumentException; use JsonSerializable; use stdClass; -use JsonSchema\Constraints\Constraint; -use JsonSchema\Validator; use Pronamic\WordPress\Money\Money; /** @@ -91,16 +89,6 @@ public static function from_json( $json ) { throw new InvalidArgumentException( 'JSON value must be an object.' ); } - $validator = new Validator(); - - $validator->validate( - $json, - (object) [ - '$ref' => 'file://' . realpath( __DIR__ . '/../json-schemas/amount.json' ), - ], - Constraint::CHECK_MODE_EXCEPTIONS - ); - return self::from_object( $json ); } diff --git a/src/Chargeback.php b/src/Chargeback.php index 0809306..121451a 100644 --- a/src/Chargeback.php +++ b/src/Chargeback.php @@ -68,19 +68,8 @@ public function get_amount() { * @link https://docs.mollie.com/reference/v2/chargebacks-api/get-chargeback * @param object $json JSON object. * @return Chargeback - * @throws \JsonSchema\Exception\ValidationException Throws JSON schema validation exception when JSON is invalid. */ public static function from_json( $json ) { - $validator = new \JsonSchema\Validator(); - - $validator->validate( - $json, - (object) [ - '$ref' => 'file://' . realpath( __DIR__ . '/../json-schemas/chargeback.json' ), - ], - \JsonSchema\Constraints\Constraint::CHECK_MODE_EXCEPTIONS - ); - $object_access = new ObjectAccess( $json ); $chargeback = new Chargeback( diff --git a/src/Line.php b/src/Line.php index 6e3109d..db07067 100644 --- a/src/Line.php +++ b/src/Line.php @@ -10,9 +10,6 @@ namespace Pronamic\WordPress\Mollie; -use JsonSchema\Constraints\Constraint; -use JsonSchema\Exception\InvalidArgumentException; -use JsonSchema\Validator; use JsonSerializable; use Pronamic\WordPress\Number\Number; use stdClass; @@ -248,16 +245,6 @@ public static function from_json( $json ) { throw new InvalidArgumentException( 'JSON value must be an object.' ); } - $validator = new Validator(); - - $validator->validate( - $json, - (object) [ - '$ref' => 'file://' . realpath( __DIR__ . '/../json-schemas/line.json' ), - ], - Constraint::CHECK_MODE_EXCEPTIONS - ); - return self::from_object( $json ); } diff --git a/src/Mandate.php b/src/Mandate.php index 1d3d62b..40ac1f4 100644 --- a/src/Mandate.php +++ b/src/Mandate.php @@ -19,19 +19,8 @@ class Mandate extends BaseResource { * * @param object $json JSON object. * @return self - * @throws \JsonSchema\Exception\ValidationException Throws JSON schema validation exception when JSON is invalid. */ public static function from_json( $json ) { - $validator = new \JsonSchema\Validator(); - - $validator->validate( - $json, - (object) [ - '$ref' => 'file://' . realpath( __DIR__ . '/../json-schemas/mandate.json' ), - ], - \JsonSchema\Constraints\Constraint::CHECK_MODE_EXCEPTIONS - ); - $object_access = new ObjectAccess( $json ); $mandate = new Mandate( diff --git a/src/Order.php b/src/Order.php index 668273e..d8fcd8c 100644 --- a/src/Order.php +++ b/src/Order.php @@ -98,19 +98,8 @@ public function get_status(): string { * @link https://docs.mollie.com/reference/v2/orders-api/get-order * @param object $json JSON object. * @return Order - * @throws \JsonSchema\Exception\ValidationException Throws JSON schema validation exception when JSON is invalid. */ public static function from_json( $json ) { - $validator = new \JsonSchema\Validator(); - - $validator->validate( - $json, - (object) [ - '$ref' => 'file://' . realpath( __DIR__ . '/../json-schemas/order.json' ), - ], - \JsonSchema\Constraints\Constraint::CHECK_MODE_EXCEPTIONS - ); - $object_access = new ObjectAccess( $json ); $order = new Order( $object_access->get_property( 'id' ) ); diff --git a/src/OrderRefundLineRequest.php b/src/OrderRefundLineRequest.php index 20c91bb..97c5391 100644 --- a/src/OrderRefundLineRequest.php +++ b/src/OrderRefundLineRequest.php @@ -10,9 +10,6 @@ namespace Pronamic\WordPress\Mollie; -use JsonSchema\Constraints\Constraint; -use JsonSchema\Exception\InvalidArgumentException; -use JsonSchema\Validator; use JsonSerializable; use stdClass; diff --git a/src/Payment.php b/src/Payment.php index c8d454e..ba483f1 100644 --- a/src/Payment.php +++ b/src/Payment.php @@ -421,19 +421,8 @@ public function get_metadata() { * @link https://docs.mollie.com/reference/v2/payments-api/get-payment * @param object $json JSON object. * @return Payment - * @throws \JsonSchema\Exception\ValidationException Throws JSON schema validation exception when JSON is invalid. */ public static function from_json( $json ) { - $validator = new \JsonSchema\Validator(); - - $validator->validate( - $json, - (object) [ - '$ref' => 'file://' . realpath( __DIR__ . '/../json-schemas/payment.json' ), - ], - \JsonSchema\Constraints\Constraint::CHECK_MODE_EXCEPTIONS - ); - $object_access = new ObjectAccess( $json ); $payment = new Payment( diff --git a/src/PaymentDetails.php b/src/PaymentDetails.php index 1ce02ea..61a07a8 100644 --- a/src/PaymentDetails.php +++ b/src/PaymentDetails.php @@ -21,23 +21,12 @@ class PaymentDetails { * @param string $method Payment method. * @param object|null $json JSON object. * @return PaymentDetails|null - * @throws \JsonSchema\Exception\ValidationException Throws JSON schema validation exception when JSON is invalid. */ public static function from_json( $method, $json ) { if ( null === $json ) { return null; } - $validator = new \JsonSchema\Validator(); - - $validator->validate( - $json, - (object) [ - '$ref' => 'file://' . realpath( __DIR__ . '/../json-schemas/payment-details.json' ), - ], - \JsonSchema\Constraints\Constraint::CHECK_MODE_EXCEPTIONS - ); - $details = new PaymentDetails(); foreach ( $json as $key => $value ) { diff --git a/src/Refund.php b/src/Refund.php index a0b30dc..7b01763 100644 --- a/src/Refund.php +++ b/src/Refund.php @@ -132,19 +132,8 @@ public function get_created_at() { * @link https://docs.mollie.com/reference/v2/refunds-api/get-refund * @param object $json JSON object. * @return Refund - * @throws \JsonSchema\Exception\ValidationException Throws JSON schema validation exception when JSON is invalid. */ public static function from_json( $json ) { - $validator = new \JsonSchema\Validator(); - - $validator->validate( - $json, - (object) [ - '$ref' => 'file://' . realpath( __DIR__ . '/../json-schemas/refund.json' ), - ], - \JsonSchema\Constraints\Constraint::CHECK_MODE_EXCEPTIONS - ); - $object_access = new ObjectAccess( $json ); $refund = new Refund( diff --git a/src/Shipment.php b/src/Shipment.php index eabf698..191a5a4 100644 --- a/src/Shipment.php +++ b/src/Shipment.php @@ -20,19 +20,8 @@ class Shipment extends BaseResource { * @link https://docs.mollie.com/reference/v2/orders-api/get-shipment * @param object $json JSON object. * @return Shipment - * @throws \JsonSchema\Exception\ValidationException Throws JSON schema validation exception when JSON is invalid. */ public static function from_json( $json ) { - $validator = new \JsonSchema\Validator(); - - $validator->validate( - $json, - (object) [ - '$ref' => 'file://' . realpath( __DIR__ . '/../json-schemas/shipment.json' ), - ], - \JsonSchema\Constraints\Constraint::CHECK_MODE_EXCEPTIONS - ); - $object_access = new ObjectAccess( $json ); $shipment = new Shipment( $object_access->get_property( 'id' ) );