chore: complete update
This commit is contained in:
35
src/Framework/Database/Middleware/QueryContext.php
Normal file
35
src/Framework/Database/Middleware/QueryContext.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Framework\Database\Middleware;
|
||||
|
||||
use App\Framework\Database\ConnectionInterface;
|
||||
|
||||
final class QueryContext
|
||||
{
|
||||
public function __construct(
|
||||
public readonly string $operation,
|
||||
public readonly string $sql,
|
||||
public readonly array $parameters,
|
||||
public readonly ConnectionInterface $connection,
|
||||
public array $metadata = []
|
||||
) {}
|
||||
|
||||
public function withMetadata(string $key, mixed $value): self
|
||||
{
|
||||
$new = clone $this;
|
||||
$new->metadata[$key] = $value;
|
||||
return $new;
|
||||
}
|
||||
|
||||
public function getMetadata(string $key, mixed $default = null): mixed
|
||||
{
|
||||
return $this->metadata[$key] ?? $default;
|
||||
}
|
||||
|
||||
public function hasMetadata(string $key): bool
|
||||
{
|
||||
return array_key_exists($key, $this->metadata);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user