PluginProbe
WCPOS – Point of Sale (POS) plugin for WooCommerce / trunk
WCPOS – Point of Sale (POS) plugin for WooCommerce vtrunk
1.10.13 1.10.14 1.10.12 1.10.11 1.10.10 1.10.9 1.10.8 untagged-3d9b7ccddc54df87c672 1.10.7 1.10.6 1.10.5 1.10.3 1.10.4 1.10.2 1.10.1 1.10.0 1.9.17 1.9.15 1.9.16 1.9.14 1.9.13 1.9.12 1.9.11 1.9.10 1.9.9 All 158 releases
woocommerce-pos / includes / Sync / Request_Int_Param.php

Request_Int_Param.php in WCPOS – Point of Sale (POS) plugin for WooCommerce trunk, at includes/Sync/Request_Int_Param.php

27 lines 757 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * WCPOS sync read surface.
4 *
5 * @package WCPOS\WooCommercePOS\Sync
6 */
7
8 namespace WCPOS\WooCommercePOS\Sync;
9
10 use WP_REST_Request;
11
12 // phpcs:disable Squiz.Commenting, Generic.Commenting -- Ported lab documentation is preserved verbatim.
13
14 /**
15 * Shared clamped-int request-param reader (previously duplicated verbatim in
16 * the changes and integrity controllers): absent/blank falls back to the
17 * default, everything is clamped into [$min, $max].
18 */
19 trait Request_Int_Param {
20 private function int_param( WP_REST_Request $request, string $key, int $default, int $min, int $max ): int {
21 $raw = $request->get_param( $key );
22 $value = ( null === $raw || '' === $raw ) ? $default : (int) $raw;
23
24 return max( $min, min( $max, $value ) );
25 }
26 }
27