GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — ModularTemplate/src/classes/APIRequestBody.php at master · FedgeNo/ModularTemplate

Expand file tree

/

APIRequestBody.php

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
37 lines (30 loc) · 986 Bytes
/

APIRequestBody.php

Copy path

File metadata and controls

37 lines (30 loc) · 986 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
declare(strict_types=1);
/** The size and shape every ordinary application API request may carry. */
final class APIRequestBody
{
public const MAX_BYTES = 24 * 1024;
/** Whether a valid JSON body is one object whose fields are all scalar or null. */
public static function hasOnlyTopLevelFields(string $body): bool
{
if ($body === '') {
return true;
}
try {
$payload = json_decode($body, false, 512, JSON_THROW_ON_ERROR);
} catch (\JsonException) {
// Endpoint validation already reports malformed input as missing
// fields; this shared layer is only the nesting boundary.
return true;
}
if (!is_object($payload)) {
return false;
}
foreach (get_object_vars($payload) as $value) {
if (is_array($value) || is_object($value)) {
return false;
}
}
return true;
}
}
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.