-
Notifications
You must be signed in to change notification settings - Fork 2
Post
Viames Marino edited this page Feb 23, 2026
·
1 revision
Pair\Helpers\Post is a helper around POST payload access.
Use Post when you want explicit POST-centric access patterns instead of mixing $_POST directly through many layers.
- Encapsulates POST data retrieval with framework-consistent semantics.
- Useful in services/models where superglobals should be minimized.
$post = new \Pair\Helpers\Post();
$email = $post->email ?? null;
$name = $post->name ?? null;$post = new \Pair\Helpers\Post();
$payload = [
'email' => trim((string)($post->email ?? '')),
'name' => trim((string)($post->name ?? '')),
];
if (!filter_var($payload['email'], FILTER_VALIDATE_EMAIL)) {
throw new RuntimeException('Invalid email');
}- Do not assume POST keys always exist.
- Always normalize/cast values before persistence.
See also: Request, Model, Controller.