PluginProbe
PostNL for WooCommerce / 5.9.12
PostNL for WooCommerce v5.9.12
5.9.12 5.9.11 5.9.10 5.9.9 5.9.8 5.9.7 5.9.6 trunk 2.5.0 2.5.1 2.5.2 2.5.3 2.5.4 2.5.5 3.1.4 3.1.5 3.1.6 3.1.7 4.0.0 4.0.1 4.0.2 4.3.2 4.3.3 4.4.0 4.4.1 All 72 releases
woo-postnl / src / Rest_API / Legacy / Postcode_Check_Service.php

Postcode_Check_Service.php in PostNL for WooCommerce 5.9.12, at src/Rest_API/Legacy/Postcode_Check_Service.php

44 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Class Rest_API\Legacy\Postcode_Check_Service file.
4 *
5 * @package PostNLWooCommerce\Rest_API\Legacy
6 */
7
8 namespace PostNLWooCommerce\Rest_API\Legacy;
9
10 use PostNLWooCommerce\Rest_API\Contracts\Postcode_Check_Service_Interface;
11 use PostNLWooCommerce\Rest_API\Legacy\Postcode_Check\Client;
12 use PostNLWooCommerce\Rest_API\Legacy\Postcode_Check\Item_Info;
13
14 if ( ! defined( 'ABSPATH' ) ) {
15 exit;
16 }
17
18 /**
19 * Class Postcode_Check_Service
20 *
21 * Stateless service wrapper around Legacy\Postcode_Check\Client.
22 * Zero-arg constructable so Service_Factory can return it before request data exists.
23 *
24 * @package PostNLWooCommerce\Rest_API\Legacy
25 */
26 class Postcode_Check_Service implements Postcode_Check_Service_Interface {
27
28 /**
29 * Check the given postcode data.
30 *
31 * @param array $post_data Post data for postcode check.
32 *
33 * @return array
34 */
35 public function check( array $post_data ): array {
36 $item_info = new Item_Info( $post_data );
37 $client = new Client( $item_info );
38
39 // send_request() can return null on an empty/non-JSON 200; normalize to honor the array return type.
40 $response = $client->send_request();
41 return is_array( $response ) ? $response : array();
42 }
43 }
44