inner = $inner; } public function str( string $key, string $default = '' ): string { $value = $this->inner->get_param( $key ); return is_scalar( $value ) ? sanitize_text_field( (string) $value ) : $default; } /** * The parameter exactly as sent. For values that are parsed and validated by the * caller (JSON), where sanitize_text_field() would change the content. */ public function raw( string $key ): string { $value = $this->inner->get_param( $key ); return is_string( $value ) ? $value : ''; } /** * A scalar parameter exactly as sent, or null when it was not sent at all. JSON bodies carry numbers * and booleans natively and forms carry strings; both come back as a string here ("1"/"" for booleans). */ public function scalar( string $key ): ?string { $value = $this->inner->get_param( $key ); if ( is_bool( $value ) ) { return $value ? '1' : '0'; } return is_scalar( $value ) ? (string) $value : null; } public function int( string $key, int $default = 0 ): int { $value = $this->inner->get_param( $key ); return is_numeric( $value ) ? (int) $value : $default; } public function bool( string $key ): bool { return rest_sanitize_boolean( $this->inner->get_param( $key ) ); } /** * @throws HttpException When the id is missing or malformed. */ public function jobId(): string { $id = $this->str( 'job_id' ); if ( 1 !== preg_match( self::JOB_ID_PATTERN, $id ) ) { throw new HttpException( 'om_bad_job_id', esc_html__( 'Invalid job identifier.', 'migratex' ), 400 ); } return $id; } public function header( string $name ): string { return trim( (string) $this->inner->get_header( $name ) ); } /** * Raw request body. Only populated for application/octet-stream chunk uploads. */ public function body(): string { return (string) $this->inner->get_body(); } }