PluginProbe
The Innovative Form Builder – IvyForms / 1.5.1
The Innovative Form Builder – IvyForms v1.5.1
1.5.1 1.5 1.4.1 1.4 trunk 0.1.2 0.2 0.2.1 0.3 0.3.1 0.4 0.5 0.6 0.6.1 0.6.1-backup 0.6.1.1 0.7 0.8 0.8.1 0.8.2 0.9 0.9.1 1.0 1.1 1.1.1 All 27 releases
ivyforms / backend / src / Infrastructure / WP / REST / RestRouteParamReader.php

RestRouteParamReader.php in The Innovative Form Builder – IvyForms 1.5.1, at backend/src/Infrastructure/WP/REST/RestRouteParamReader.php

33 lines 728 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * @copyright © Melograno Venture Studio. All rights reserved.
5 * @licence See COPYING.md for license details.
6 */
7
8 declare(strict_types=1);
9
10 namespace IvyForms\Infrastructure\WP\REST;
11
12 use WP_REST_Request;
13
14 /**
15 * Reads positive integer route/body params from a WP REST request.
16 */
17 final class RestRouteParamReader
18 {
19 /**
20 * @param WP_REST_Request<array<string, mixed>> $request
21 */
22 public static function getPositiveIntParam(WP_REST_Request $request, string $key = 'id'): ?int
23 {
24 $raw = $request->get_param($key);
25 if ($raw === null || $raw === '' || !is_scalar($raw)) {
26 return null;
27 }
28 $id = (int) $raw;
29
30 return $id > 0 ? $id : null;
31 }
32 }
33