# ivyforms/1.5.1/backend/src/Infrastructure/WP/REST/RestRouteParamReader.php

The Innovative Form Builder – IvyForms, version 1.5.1. 33 lines.

- Page: https://pluginprobe.com/plugins/ivyforms/1.5.1/code/backend/src/Infrastructure/WP/REST/RestRouteParamReader.php
- Raw: https://pluginprobe.com/plugins/ivyforms/1.5.1/raw/backend/src/Infrastructure/WP/REST/RestRouteParamReader.php
- Modified: 2026-08-25T13:32:38+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/ivyforms/1.5.1/code/backend/src/Infrastructure/WP/REST/RestRouteParamReader.php#L10-L20`.

```php
<?php

/**
 * @copyright © Melograno Venture Studio. All rights reserved.
 * @licence   See COPYING.md for license details.
 */

declare(strict_types=1);

namespace IvyForms\Infrastructure\WP\REST;

use WP_REST_Request;

/**
 * Reads positive integer route/body params from a WP REST request.
 */
final class RestRouteParamReader
{
    /**
     * @param WP_REST_Request<array<string, mixed>> $request
     */
    public static function getPositiveIntParam(WP_REST_Request $request, string $key = 'id'): ?int
    {
        $raw = $request->get_param($key);
        if ($raw === null || $raw === '' || !is_scalar($raw)) {
            return null;
        }
        $id = (int) $raw;

        return $id > 0 ? $id : null;
    }
}

```
