Post - viames/pair GitHub Wiki
Pair framework: Post
Pair\Helpers\Post is a helper around POST payload access.
When to use
Use Post when you want explicit POST-centric access patterns instead of mixing $_POST directly through many layers.
Main behavior
- Encapsulates POST data retrieval with framework-consistent semantics.
- Useful in services/models where superglobals should be minimized.
Implementation examples
Basic usage
$post = new \Pair\Helpers\Post();
$email = $post->email ?? null;
$name = $post->name ?? null;
Validation flow
$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');
}
Common pitfalls
- Do not assume POST keys always exist.
- Always normalize/cast values before persistence.
See also: Request, Model, Controller.