Files
breadcrumb-the-shire/core/Http/Input/RequestInput.php
fs 0e86925464 refactor: rename lib/ to core/ for clearer core-module separation
Rename the top-level lib/ directory to core/ so the project root
immediately communicates which code is core platform and which lives
in modules/. PHP namespaces (MintyPHP\*) are unchanged — only the
Composer PSR-4 path mapping moves from lib/ to core/.

Module-internal lib/ directories (modules/*/lib/) are untouched.

Updated across the full stack:
- composer.json PSR-4 mapping
- bootstrap entry points (web/index.php, bin/*, tests/bootstrap.php)
- tooling configs (phpstan.neon, phpunit.xml, php-cs-fixer)
- 26 architecture contract tests
- enforcement-policy, guard-catalog, quality-gates
- all documentation (CLAUDE.md, README, 25 docs/, .agents/skills/)
- bin/qa-extended.sh search paths
- .claude/settings.local.json permission paths

Workflow: .agents/runs/CORE-LIB-RENAME-001/ (Analyst → Planner →
Executor → Code Review (4 findings fixed) → Security Review →
Acceptance Test → Finalizer)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-13 23:20:42 +02:00

138 lines
3.0 KiB
PHP

<?php
namespace MintyPHP\Http\Input;
use MintyPHP\Http\Request;
final class RequestInput
{
/**
* @param array<string, mixed> $query
* @param array<string, mixed> $body
* @param array<string, mixed> $files
*/
public function __construct(
private readonly string $method,
private readonly array $query,
private readonly array $body,
private readonly array $files
) {
}
public function method(): string
{
return $this->method;
}
public function isMethod(string ...$methods): bool
{
foreach ($methods as $method) {
if ($this->method === strtoupper(trim($method))) {
return true;
}
}
return false;
}
/**
* @return array<string, mixed>
*/
public function queryAll(): array
{
return $this->query;
}
public function query(string $key, mixed $default = null): mixed
{
return array_key_exists($key, $this->query) ? $this->query[$key] : $default;
}
public function hasQuery(string $key): bool
{
return array_key_exists($key, $this->query);
}
public function queryString(string $key, string $default = ''): string
{
return trim((string) $this->query($key, $default));
}
public function queryInt(string $key, int $default = 0): int
{
return (int) $this->query($key, $default);
}
/**
* @return array<int|string, mixed>
*/
public function queryArray(string $key): array
{
$value = $this->query($key, []);
return is_array($value) ? $value : [];
}
/**
* @return array<string, mixed>
*/
public function bodyAll(): array
{
return $this->body;
}
public function body(string $key, mixed $default = null): mixed
{
return array_key_exists($key, $this->body) ? $this->body[$key] : $default;
}
public function hasBody(string $key): bool
{
return array_key_exists($key, $this->body);
}
public function bodyString(string $key, string $default = ''): string
{
return trim((string) $this->body($key, $default));
}
public function bodyInt(string $key, int $default = 0): int
{
return (int) $this->body($key, $default);
}
/**
* @return array<int|string, mixed>
*/
public function bodyArray(string $key): array
{
$value = $this->body($key, []);
return is_array($value) ? $value : [];
}
/**
* @return array<string, mixed>
*/
public function filesAll(): array
{
return $this->files;
}
/**
* @return mixed
*/
public function file(string $key, mixed $default = null): mixed
{
return array_key_exists($key, $this->files) ? $this->files[$key] : $default;
}
public function hasFile(string $key): bool
{
return array_key_exists($key, $this->files);
}
public function wantsJson(): bool
{
return Request::wantsJson();
}
}