From 3d2c0487b790dd74b82ea0b31e3e3f0460aed390 Mon Sep 17 00:00:00 2001 From: Haylan Date: Wed, 8 Jul 2026 06:50:56 +0200 Subject: [PATCH] feat(store): fist stepts for implement ContributionStore for managing contributions in SQLite --- config/reference.php | 3 ++- src/Service/ContributionStore.php | 35 +++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 src/Service/ContributionStore.php diff --git a/config/reference.php b/config/reference.php index ea15291..cd63856 100644 --- a/config/reference.php +++ b/config/reference.php @@ -121,7 +121,7 @@ use Symfony\Component\Config\Loader\ParamConfigurator as Param; * } * @psalm-type ServicesConfig = array{ * _defaults?: DefaultsType, - * _instanceof?: InstanceofType, + * _instanceof?: array, * ... * } * @psalm-type ExtensionType = array @@ -857,6 +857,7 @@ use Symfony\Component\Config\Loader\ParamConfigurator as Param; * http_errors?: bool|Param, * expect?: mixed, * ssl_key?: mixed, + * force_ip_resolve?: mixed, // Default: null * stream?: bool|Param, * synchronous?: bool|Param, * read_timeout?: scalar|Param|null, diff --git a/src/Service/ContributionStore.php b/src/Service/ContributionStore.php new file mode 100644 index 0000000..7d61f90 --- /dev/null +++ b/src/Service/ContributionStore.php @@ -0,0 +1,35 @@ +dbPath))){ + mkdir(\dirname($this->dbPath), 0755, recursive: true); + } + $this->pdo = new PDO('sqlite:' . $this->dbPath); + $this->pdo->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION); + $this->prepareSchema(); + } + + private function prepareSchema():void{ + $this->pdo->exec(' + CREATE TABLE IF NOT EXISTS contributions ( + provider TEXT NOT NULL, + date TEXT NOT NULL, + count INTEGER NOT NULL CHECK (count >= 0), + PRIMARY KEY (provider, date) + ) WITHOUT ROWID, STRICT + '); + } + +}